pagarcia
(Pablo Garcia-Amorena)
January 21, 2020, 11:02am
9
Hi @rgr ,
I found a solution for this by attaching user data to my geometry in the custom grips class NewGeometry()
. The Rhino geometry is then converted to my custom geometry during copy/paste/load events by vtable modification .
From what I see in your video, I’d override Draw()
in both your custom object and custom grips to draw the annotation marks, most probably through a conduit.
Here an insightful quote by Dale about this topic and two related threads:
(Alternative to C++ vtable modification to promote objects on document load )
(Copy pasting custom rhino mesh object subclasses )
First, Rhino does not allow for a true custom object. If we did, would be possible to distribute 3dm files that others could not open without your plug-in.
However, you are allowed to derive classes from our run-time object classes, such as CRhinoPointObject
, CRhinoCurveObject
, CRhinoBrepObject
, etc. and override any virtual members you want.
If your derived class has additional data, then for this data to persist it must be store as user data using a class that derives from ON_UserData
. The reason for this is that custom objects do not serialize - Rhino will only serialize Rhino objects. By storing your data as user data on the object, your custom data will persist.
When reading a 3dm file, again, Rhino only reads Rhino objects. However, when a Rhino object is read, your attached user data will also be read (by your plug-in).
At some point, when the file I/O has completed, you have the opportunity to convert the Rhino object, along with your attached user data, to your own object. One way of doing this is by using the vtable slight-of-hand, which is the most efficient. Another way is to construct one of your objects from the user data and then call CRhinoDoc::ReplaceObject
as you’ve mentioned.
1 Like