UserData OnDuplicate not being called when copy paste is used?


I am working with custom user data on Rhino Objects. I am able to handle updating needed fields when the OnDuplicate method is called when the user issues a copy command. It seems however that this method is not called if a user uses the short cut copy paste on an object?

Any clarification would be helpful.


(Dale Fugier) #2

Hi Joel,

Rhino’s CopyToClipboard/Paste feature is really a file IO operation (e.g. Export, Import). Thus, you should expect your user data object’s UserData.Write and UserData.Read overrides to be called, if your user data support serialization.

Does this help?

– Dale


yes I noticed that the plugin went into read mode… okay I should be able to work with this.

thanks Dale.


is there a way to grab the objects being merged in the OnEndOpenDocument eventhandler? this way I can catch my objects that have been copied?


scratch that. it all makes sense now. I have a state on my data to let me know if it is current, loading, or copied. Handles perfectly now and pastes into a fresh rhino file as expected.


One more question here.

My write method hits a database and it does so once for every object I am tracking. Is there a way to bundle all of this on the rhino side so I can place this into a transaction for everything at once?

Thanks again,


(Dale Fugier) #7

Hi Joel,

I believe the best way to handle stuff like this is to set a flag when an interesting event occurs, such as your data is copied or pasted. Then, when Rhino’s RhinoApp.Idle event is triggered, check the flag and, if dirty, do what it takes to reset the flag (such as hit your database).

Does this help?

– Dale


this is exactly what is happening during a running session however when the file is written to .3dm the data is serialized using the RhinoCommon Binary Archive Writer.

I would still like to write the table entry to file on the rhino object but not have to call the database one at a time.

(Dale Fugier) #9

Hi Joel,

You know when Rhino is saving, by way of event watchers. So you could allow Rhino to save and then when it goes idle then hit your database.

A somewhat more drastic approach is to not store your data on each object, but rather to maintain a central table somewhere (probably on your plug-in object). Then save this data as document data in the 3dm file, which would save all of your data and hit your database all at one time. My user data sample demonstrates this.

– Dale



Thank you,



Could you give the solution ?

(Dale Fugier) #12

Could you be more specific?


having the solution to manage the shortucut copy-paste so it copy the objects with the UserDatas. Is it possible?

(Dale Fugier) #14

Have you read this entire thread? The question (above) seems to be answered…