How to get a selected Text contain with ghPython?

I am trying to use WindowPick of rhinoscriptsyntax to select Text object. How can I get the actual string of the selection and sent it as an output value? Thank you in advance!

rs.TextObjectText(sel) ?

https://developer.rhino3d.com/api/RhinoScriptSyntax/#geometry-TextObjectText

Otherwise, try print(dir(sel)), and see if there’s an obvious method. Or if WindowPick is returning a GUID and GhPython isn’t automagically resolving that to its object (test this with print(rs.IsText(sel))), you need to get a reference to the object, e.g. with the try-coerce rhutil function, or by looking it up in the RhinoDoc Object table.

Thank you James, I managed to read it by use DisplayText method of an text object by rs.coercerhinoobject(). Your rhino syntax method seems to be more handy!

1 Like