How to Get "Attribute User Text" in Grasshopper?

I create an object in Rhino, and then I add a key/value pair in this Attribute User Text section. And then I would like to access that kv pair in Grasshopper somehow, but I can’t figure it out. Object will be a Brep. I can do python or C# scripting if needed.

I have tried brep.GetUserString(“key”) but that gives me null. Interestingly, I can SetUserString and then get the user string via GH, but the kv pairs I set that way do not show up in the “Attribute User Text” panel, which makes me think I’m barking up the wrong tree.

TIA.

See Modify object C#
… did you do .CommitChanges() ?

2 Likes

Well, I only need to GetUserString as I will be setting them manually when I create the object in Rhino (GH will use the info to create other objects that work in conjunction with the object I create), but that thread did it for me.

I used…

  private void RunScript(Guid x, ref object A)
  {

    Rhino.DocObjects.RhinoObject obj = this.RhinoDocument.Objects.FindId(x);
    string v = obj.Attributes.GetUserString("test");
    A = v;

  }

And that spat out the value “xyz” as I wanted.

Thanks!!!

1 Like

When I’ve needed to do this in the past, I’ve used the “Get User Attributes” component from Elefront.

2 Likes