Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

run a function ignored by Undo Queue

5 REPLIES 5
Reply
Message 1 of 6
bmagner888
683 Views, 5 Replies

run a function ignored by Undo Queue

So i'm building a custom HUD and querying all sorts of camera data that gets updated every frame. 


Each hud element has it's own hud command, such as getTilt() which queries the active camera's rotateX value.
Obviously this needs to execute at every frame.  When you change frames it enters all of the hud commands into the undo  queue, so the user has to undo twenty times just to undo an actual user action, or even just go back to the previous frame.

If I could, I would combine all the hud element commands into one single function
stateWithoutFlush=False
run all hud element commands
stateWithoutFlush=True


But the headsUpDisplay() command seems to be designed such that each element has its own command, and will auto run at every time change.

I've tried nesting the stateWithoutFlush commands inside the hud element commands, but the queue doesn't turn back on, and because it's nested, the encapsulating function still enters the queue.

So how do i execute a function that the undo queue will ignore? 

 

Thanks for any assistance.

Labels (4)
5 REPLIES 5
Message 2 of 6
g2m.agent
in reply to: bmagner888

Based on my very limited knowledge, if you want to achieve your goal, you need to write a new plugin using API.

Message 3 of 6
zewt
in reply to: bmagner888

I tried reregistering a HUD in a timeChanged event callback, but it didn't add anything to the undo queue.  Can you show your code?  This is what I tried:

 

https://gist.github.com/zewt/575bf7f013a75ffa90fcae1a74e777ae

 

Make sure you're not changing the selection, since that does create an undo entry.

 

stateWithoutFlush should work, but it's usually only used when actually making changes to the scene that shouldn't be undoable.  If you do use stateWithoutFlush, make sure it always restores correctly even on error, or else it'll end up turning off the user's undo completely, which is a really common problem with undo.  I use this helper to be sure: https://github.com/zewt/zMayaTools/blob/master/scripts/zMayaTools/maya_helpers.py#L566

 

Message 4 of 6
bmagner888
in reply to: bmagner888

Thanks for your input.  I'm still trying to find a solution, but the problem might not be what I think it is.  Sill investigating...

Message 5 of 6
olarn
in reply to: bmagner888

There is one such command that will probably do what you wanted

https://help.autodesk.com/cloudhelp/2020/ENU/Maya-Tech-Docs/CommandsPython/undoInfo.html

cmds.undoInfo( openChunk=True )
# ...
cmds.undoInfo( closeChunk=True )
Message 6 of 6
zewt
in reply to: olarn

That groups commands into a single undo action.  The stateWithoutFlush he's using is used to run commands outside of the undo queue, which should work for what he's doing (not sure why it isn't).

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report