Undo repeats all frames, any way to speed it up? (cmds.unfoInfo)

Hi!

I’m simulating some stuff in python, basically it’s a loop that runs through each frame of the animation, performing some actions.

At the start I usecmds.undoInfo(ock=1) and in the end cmds.unfoInfo(cck=1)

This way at the end of the simulation I can hit Ctrl+Z once and it does undo all of it, but the only problem is that it’s doing it frame by frame which is kind of slow.

Is there any way to speed it up, or is it just a limitation of undo in Maya?

It’s probably not fixable in that each of those operations (including the frame time changes) is still generating entries in the internal undo queue which need to be played back in order to get back to the state before the operation.

Maybe it would be simpler to write a tool that checkpoints the file before the op and then just reloads it if you don’t like the results?

1 Like

Maybe, but it really depends on how heavy the file is, and how long the animation is. It could probably end up about the same to reload the scene.

Creating a new animation curve node without removing the old one and plugging that back, or using animation layers could work though, I guess.

Thanks! :slight_smile:

Perhaps you could speed it up by disabling all viewports?
https://blog.asimation.com/disable-maya-viewport-while-running-code/

It does not work for undo. During simulation viewport is grey, but when you undo it shows everything still.