Add Name attribute to a RhinoDoc object

I am trying to add a name attribute to a rhinodoc object, similar to the ObjectName method in rhinoscript\ However, CommitChanges returns False. How can I work around this?


doc = Rhino.RhinoDoc.New(None)
Rhino.RhinoDoc.ActiveDoc = doc

crv = Rhino.Geometry.ArcCurve()
guid = doc.Objects.AddCurve(crv)
obj = doc.Objects.FindId(guid)
obj.Attributes.Name = 'test'
obj.CommitChanges() #This returns False

Hi @pgs,

Where are you running this code? From within the Rhino WIP? From CPython?


– Dale

Hi, I am running the code from Cpython using rhinoinside

Hi @pgs,

How about this?

import rhinoinside
import Rhino

doc = Rhino.RhinoDoc.CreateHeadless(None)
plane = Rhino.Geometry.Plane.WorldXY
arc = Rhino.Geometry.Arc(plane, 5.0, 0.785398)
arc_curve = Rhino.Geometry.ArcCurve(arc)
if arc_curve.IsValid:
    attributes = doc.CreateDefaultAttributes()
    attributes.Name = 'Rhino.Inside Python test'
    obj_id = doc.Objects.AddCurve(arc_curve, attributes)
    doc.Write3dmFile('/users/dale/desktop/test.3dm',  Rhino.FileIO.FileWriteOptions())

– Dale