RhinoCommon User Data OnDuplicate Method

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?

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.

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.

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?

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

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?