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\object.py. However, CommitChanges returns False. How can I work around this?

Pål

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?

Thanks,

– Dale

Hi, I am running the code from Cpython using rhinoinside

Hi @pgs,

How about this?

import rhinoinside
rhinoinside.load()
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)
    print(obj_id)
    doc.Write3dmFile('/users/dale/desktop/test.3dm',  Rhino.FileIO.FileWriteOptions())
doc.Dispose()

– Dale