How do store object text as a variable with rhino python?


I am new here and new to python as well. Sorry in advance if this has been discussed or if my question doesn’t belong here.

The fun part:
I have been tasked with creating a script that takes part information from Rhino (length and area of each part by layer) to export to excel to create a database of part information. This will be used further in several calculators.

I have been making progress writing snippets to achieve those goals and now Im moving on to the actual exporting to CSV process of the script. All of our part numbers appear on our “design template” according to the name of the filename (using %< filename(3") >%) under the object properties.

So basically, I want the user to select an object, and then have the actual text of that object stored as a string inside a variable. It will only be one object that is selected.

currently this is the closest to the solution I have found:

filename = rs.GetObject()
print rs.GetUserText(filename)

When debugging I see that there is a text value stored inside “Rhino.Docbjects.TextObjects.DisplayText” but I have no clue on how to access that part of it.

Hints, Help, or Suggestions would be greatly appreciated!

I’m not sure I understand what your actual situation is.

Are you referring to the displayed text of a text-object?
How about this:

object = rs.GetObject()
print rs.TextObjectText(object)


Exactly what I needed. Much appreciated @willem

1 Like


I finally finished writing my first program :smile:

Any ideas on how I can make a rhino toolbar button out of this so that everyone in the CAD department can utilize this script with one easy click?