Undo / Redo event


I’ve been looking over the custom undo event command and several of the provided examples for the method AddCusomUndoEvent. [ ie. doc.AddCustomUndoEvent(“Name”,Handler method); ]

I’ve been trying to understand this method in order to use it to count the number of undos and redos commanded by a user. I’m using these counts to coordinate specific data in a custom plugin with rhino and I’m writing because it appears that the provided method seems to require a command to enable it rather than just refer to the event itself - an event would be much more helpful.

My questions are:

  1. Is there an event that I can subscribe to instead of using the above method?
  2. If there is an event is there another event for ‘redo’?

I do hope events are available. I see other similar events but nothing strictly for undo / redo.

  1. No
  2. No

You add an event handler when you add the custom undo. At that point in time the user can undo the last action. After that they can redo it, so you must add the event handler again during the undo event handling. Then when the user redoes the action, you can see in the event args CreatedFromRedo is true. Now you know the user has performed redo. Again, while you respond to this redo, you must again add the undo event handler. And so on, and so forth.