Can RhinoCommon set Rhino object names?

Rhino objects have their names exposed via RhinoObject.Name, but this property is read-only. Is there a way to programmatically set the names of existing objects with RhinoCommon?

Hi,

Seems like it could be done through scriptcontext.doc.Objects.ModifyAttributes:

import rhinoscriptsyntax as rs
import scriptcontext as sc

id = rs.GetObject("pick something")
rh_obj = rs.coercerhinoobject(id)
attrib = rh_obj.Attributes
sc.doc.Objects.ModifyAttributes(rh_obj, attrib, True)
rh_obj.Attributes.Name = "someName"
rh_obj.CommitChanges()

Check the object.py file

djordje,

I see that this is an old posting but I have a question for you. Once you give the object a name is there a simple way to select it on screen by it’s name?

Eric

@eric.bunn,

Rhino has a SelName command .

Does this help?

– Dale

1 Like

Hi Eric,
You can call “SelName” command through rs.Command function, as Dale showed.
Or call rs.SelectObjects:

import rhinoscriptsyntax as rs

name = "Jelisaveta"  # name applied to one or more objects
id_L = rs.ObjectsByName( name )
rs.SelectObjects( id_L )

Thank you djordje.

Eric