@pagarcia wrote:
Hello,
I need help to handle a custom CRhinoUndoEventHandler.
My plugin adds custom mesh objects into the document, each of them having an instance of custom ON_UserData attached. The commands receive some user interaction as input, update the user data and replace the object with an updated mesh.
From Dale's SampleCustomUndo I see that my
CRhinoUndoEventHandler
should have as member an instance of my data (which will store its "old" version before the user does Undo), and inside the virtualUndo
I should code the way of doing Undo operation. Inside my plugin, I'd useAddCustomUndoEvent
with the current data before running any command.However, I have three crucial questions:
1) When I write data, I don't know whether it's my ON_UserData or the linked CRhinoMeshObject that "lives" in the document, or both.
2) For me, my custom user data and the mesh object are the same: when an instance of user data is updated, its corresponding mesh is updated and replaces the old one. In the undo event handler, where do I perform the operation of replacing the last mesh with the old one?
In the header I read "Never change any setting in the Rhino document or application", which leads me to confusion (whether the operation of replacing a mesh is a change of settings, etc).
3) In Dale's sample I see that the operations coded in
Undo
modify an instance of data (adouble
value) that is a private member ofCRhinoUtilityPlugIn
. Why is this necessary? I assume that it is for easy tracking of the data to be "undone", but what's the way to do it with multiple objects that are in the document?For example, I have a command that takes as input 2 custom meshes A and B and as output gives two new meshes C and D, being C the updated version of A and D the updated version of B. If the user does Undo and I want to recover A/B from C/D, I don't know how to track them properly from the members in the undo handler and the document.
Any idea or hint will be very appreciated!
Pablo
Posts: 3
Participants: 2