pgs
(Pål Grøthe Sandnes)
October 15, 2019, 1:38pm
1
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
dale
(Dale Fugier)
October 15, 2019, 3:27pm
2
Hi @pgs ,
Where are you running this code? From within the Rhino WIP? From CPython?
Thanks,
– Dale
pgs
(Pål Grøthe Sandnes)
October 15, 2019, 9:48pm
3
Hi, I am running the code from Cpython using rhinoinside
dale
(Dale Fugier)
October 15, 2019, 10:04pm
4
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