Modify object C#

I would like to replace the object from Rhino with a new url, like Elefront’s modifyobjectAttribute.
However, currently I can’t replace it and it gets baked.

Can someone please tell me where to go from here?test.gh (6.7 KB)
test.3dm (28.9 KB)

Hi!

of course, because with Rhino.DocObjects.Tables.ObjectTable .Add you specifically add a new object.
… you could use .Replace to replace it instead…


A simpler solution is to just edit the specific attributes of your object, and lastly do .CommitChanges to actually make the edits go to the rhino file.

Any “referenced” object can be directly casted to the Guid type: (see the type hint)

And then it is pretty straightforward:

 private void RunScript(bool button, Guid ID, string key, string value, string url)
  {
    if(button)
    {
      Rhino.DocObjects.RhinoObject obj = this.RhinoDocument.Objects.FindId(ID);
      obj.Attributes.Url = url;
      obj.Attributes.SetUserString(key, value);
      obj.CommitChanges();
    }
  }

test re.gh (4.8 KB)

2 Likes

oh…CommitChanges();…
I’ve been wondering about this all day. Thank you very much for your help. :joy: