RhinoCommon User Data OnDuplicate Method


#1

As I understand it when an object that has my custom User Data class is copied the OnDuplicate method is called. How do I get a reference to this new RhinoObject that is produced?


(Menno Deij - van Rijswijk) #2

The idea is that you don’t need the newly produced object. The data should duplicate itself, and the system will attach it to the copied object.


#3

This is in fact the case, however I have need to keep track of both the Rhino Object and the User data in an in memory persistence class. When objects are copied I need to then add the new rhino object to my mapping.


#4

You should be able to catch the rhino event RhinoDoc.AddRhinoObject using (in VB at least) an AddHandler statement.
From the event arguments you can get the new object that was added.

This is what I’m doing to keep track of user data when the ‘holding’ object is moved or deleted.

If you do go down that route, you might want to read this thread: DeleteRhinoObject Event for multiple objects?


#5

I will try this. I am using similar events to track deleted objects at the moment.


#6

Why not just handling the:

RhinoDoc.AddRhinoObject += new EventHandler(OnAddObject);

Combined with RhinoDoc.EndOpenDocument which fires as well and e.Merge equals true when pasted was performed?

That should give one the Guid’s of the new objects? Is there something wrong with this approach?

Thanks
Christian