Get usertext in grasshopper

I have a few breps that has attribute usertext in them. I link those into GH and send them into a GHpython component. In there the rs.GetUserText() gives me nothing. What do I miss?

I think Grasshopper make a copy of the object for internal uses. It prevents bad uses from users. There are many discussions on this subject. So as object is duplicated there is no copy of useless information for Grasshopper (everything that is not geometry ?).
Instead you have to get object by reference. So use GUID as input. Here a very simple example. Could not be the best way as I discoverd it now

See discussions on this subject here

You can also use Elefront which uses a lot referenced object.
Edit :
A more generic code
Rhino.DocObjects.RhinoObject ee = doc.Objects.Find(id);
System.Collections.Specialized.NameValueCollection keyValue = ee.Attributes.GetUserStrings();
keys = keyValue.AllKeys;
List allValues = new List();
foreach(string key in keyValue.AllKeys)
values = allValues;

get user (7.4 KB)

I was trying to duplicate what elefront does with my own python so there is no dependency but I guess it’ll have to be C#

I anwsered with C# because I don’t use Python. I have no idea if everything in C# could be replicated in Python, but documentation says that Rhinocommon is in C#, Python and VB. So it must be possible you stay in Python.

I prefer C# (same for VB) because I now make some dll to be used in my program. So I can put some complex calculation in one C# instead of having a “Spaghetti” definition …

Hi @laurent_delrieu, the component above seems to point to nowhere. Can you update it please ?


1 Like

This is how I modified the script for my own use. Hope it can help someone. Basically replaces one little function within elefront. (12.9 KB)

1 Like