How to change object's name in Rhino with GHpython?

:grinning:Hello All!
I want to change object’s name directly with GHpython.
I tried this but failed, after I run this the name didn’t change in rhino:

import scriptcontext as sc
import Rhino as rh
sc.doc = rh.RhinoDoc.ActiveDoc
obj = sc.doc.Objects.Find(id)
obj.Attributes.Name = "ChangedName"
sc.doc = ghdoc

can ghpython achieve this function? That would be very helpful to me.

Hello - it looks like you need to add

obj.CommitChanges()

-Pascal

That’s it!! Thank you Pascal Golay!