mcneel / rhino3dm

Libraries based on OpenNURBS with a RhinoCommon style
MIT License
574 stars 135 forks source link

Implement File3dmNotes for python and javascript #564

Closed coditect closed 2 months ago

coditect commented 10 months ago

This pull request adds bindings for File3dm.Notes and the File3dmNotes class.

coditect commented 10 months ago

I'm not satisfied with the way the Notes getter on File3dm returns a File3dmNotes that stores a copy of the ONX_Model's ON_3dmNotes object instead of referencing the original. This can lead to unanticipated results in Python and JavaScript when trying to alter a model's notes. For example, the following does not work as one might expect:

myFile = File3dm.Read("/path/to/my/model.3dm")
myFile.Notes.Notes = "These are my new notes"
print(myFile.Notes.Notes) # does not print the new notes

Instead, one has to reassign the modified File3dmNotes back to File3dm.Notes:

theNotes = myFile.Notes
theNotes.Notes = "These are my new notes"
myFile.Notes = theNotes
print(myFile.Notes.Notes) # now it prints the new notes

This situation could be rectified by storing a reference or pointer to ON_3dmNotes inside the File3dmNotes class, but at the expense of added complexity. Since this problem occurs elsewhere in rhino3dm (LineCurve.Line, for example), I wanted to get the input of @fraguada or @sbaer before introducing a new pattern into the library.