Rename objects / Assign custom Objects attributes

Dear all,

I need to rename/assign to rhino objects specific names. I tried with the solution at the following link, but with no luck (https://developer.rhino3d.com/samples/rhinocommon/rename-object/).

I need also to assign specific Attributes (keys:values) - any chance to it in GHPython?

Thanks in advance for your help.

Nicola

1 Like

Rhinocommon:

import Rhino
rh_obj = Rhino.RhinoDoc.ActiveDoc.Objects.Find(id)
rh_obj.Attributes.Name = name
rh_obj.Attributes.SetUserString(key, value)
rh_obj.CommitChanges()

rhinoscriptsyntax:

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc
rs.ObjectName(id, name)
rs.SetUserText(id, key, value)

Attributes.gh (4.6 KB)

1 Like

Thanks a lot Mahdiyar! Super useful!

Kind Regards

Nic