Undo/redo doesn't work directly with the maya.api.OpenMaya API, and there are workarounds that needs to be done in order to do so. I've found some older resources but I lack the knowledge to understand them completely and I don't know if they can work as a generic solution.
I try to create a general solution that can handle object creation, component editing and deletion, selection etc., if possible.
Can someone can further explain how they are to be used with python? How is a command added to the queue? should a custom undo be created for every command or is it handled automatically?
I see that MPxCommand and MDGModifier are used for this, but any command that is not part of the cmds module will throw an error when calling the MDGModifier.doIt() - for example MDGModifier.pythonCommandToExecute("my_test_fn()").
These are the scarce resources I've found so far:
- https://www.youtube.com/watch?v=BZyXe3MhEyI
- https://github.com/mottosso/cmdx/blob/4a6284cf613b786306f2887b27fb46e33570f52f/cmdx.py#L4037
- https://www.youtube.com/watch?v=pK0oVnZdmYg&t=71s
The third one is a Chinese video that I don't understand, but it may contain valuable data.