Hello, I have been toiling around quite a bit trying to figure out how to read a value from the ‘Attribute User Text’ tab of an object once it is selected, where the attributes dictionary is. My objects on my model all have an attribute key called “json” and I want to be able to pull that value out but whenever I use the rs.GetUserText() function, all I receive is ‘None’. I have tried using rs.GetDocumentUserText() and this does not get me what I want either. Can anyone please provide some direction?
My end goal with my script is to select all object, get their json data from this attribute and write it to a json file.
Thank you for your time.
import rhinoscriptsyntax as rs
import Rhino.PlugIns.PlugInDescriptionAttribute as rp
import Rhino.PlugIns.PlugInInfo as plinfo
import Rhino.PlugIns.PlugIn as plug
objs = rs.GetObjects("Select Objects")
userTexts = 
names = 
descs = 
for obj in objs:
userTexts.append(rs.GetUserText(obj, "json", True))
desc = rs.ObjectDescription(obj)
results = rs.PropertyListBox(objs, userTexts, "Modify object name(s)")
rs.GetUserText(obj, "json", True)
I changed that last argument to
False and it works for me.
By default user texts are NOT attached to geometry, as it seems to me.
attached_to_geometry (bool, optional): location on the object to retrieve the user text
I’m not sure I understand the use case for this.
as far as i know, one that is listed here in this tab is on the object attribute
if a user text is set on the geometry, you can programmatically access it without “baking” it into the scene.
Will, thanks for your input. I got stuck and had to move off the project shortly after posting, but will try it when I’m back on it. Thanks!