Implementing UNDO

ruimac

Member
How can I make sure that any action that I carry on in a script that changes containers or keyframes, is undoable?
 
So, should I assume that it is not possible to store previous states of containers, keyframes, channels, etc, to be able to perform an Undo, after a script is executed?
 
I don't think there is an easy way around this, you have to 'record' every action you make in the script to an array and then when triggering the undo apply these actions
 
How can I detect the Undo, to trigger the recorded actions, if I decide to implement that recording?
 
I don't know a way to do that, I think maybe you should make your own 'undo' button in the script that will trigger the recorded actions
 
I don't know a way to do that, I think maybe you should make your own 'undo' button in the script that will trigger the recorded actions

Thank you. I guess I will have to do that.
Before starting coding in Viz, I did lots of coding in Cinema 4D and it was quite easy to store whatever I wanted in the Undo pool, so that the user could easily revert to the pre-script-execution state.
 
I found these set of commands while searching for something else, looks like it could help
I don't know how to trigger them but please share if they were helpful
 

Attachments

  • UndoRedoCommands.png
    UndoRedoCommands.png
    203.7 KB · Views: 2
I have tried to use the System.SendCommand to evoke the "START_UNDOABLE_OPERATION" but I got an error, so I assume it is not the way to use it.
In a nutshell, I could not use any of the commands.
It would be great to have a way to store the current state of the document before doing any changes using code, so that the user could revert to the previous state, after running a script.
 
Back
Top