Multiple CustomUndoEvent Registration issue

I’m trying to better understand the limitations of Rhino’s Custom Undo Event System. In in the process have encountered what I believe to be a bug.

I started working on custom undo/redo based upon this discussion: Registering Multiple Custom Undo Events. In the discussion @dale mentions that Rhino doesn’t support registering multiple custom undo events per command. Wanting to get this right I built a test solution to explore this limitation: github: Rhino3dCustomUndoEventIssue. I got to a place where I’m fairly confident on creating an maintaining a separate undo/redo stack and keeping it synced with rhino’s undo/redo system.

The reason I’m posting this as a bug is that I discovered that it’s possible to cause unexpected behavior when interacting with commands from other plugins that register custom undo events. The minimal case required to reproduce this behavior is to take the TestEarnTen and TestSpendFive commands in the example and string them together with a ScriptRunnerCommand: TestEarnCommands.cs When you execute and then undo this command it undoes TestEarnTen Twice instead of undoing test spend five and then undoing test earn ten.

I hope the example helps.

If there’s a more detailed right up for the UndoRedoEventArgs class and what it’s expected values are in what state that would be much appreciated. For instance I discovered through testing that when undoing or redoing the CommandId is the command Id for the associated Undo/Redo event but is the CommandId of the of the command that was undone when recording is ended.

-Cullen