Created
June 13, 2013 15:08
-
-
Save hogjonny/5774453 to your computer and use it in GitHub Desktop.
This is a block of code, which creates a Class for managing Undo chunking in Autodesk Maya, Python scripts.
I have tested this in my Maya 2011 setup, and it works great.
This code snippet came from Rob Galanakis, via Tech-artist.org forums:
http://tech-artists.org/forum/showthread.php?2522-Undo-in-Maya-(Mel-Python-Execution)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as mc | |
########################################################################### | |
## This wraps commands in a maya UndoContext | |
# ------------------------------------------------------------------------- | |
class UndoContext(object): | |
def __enter__(self): | |
mc.undoInfo(openChunk=True) | |
def __exit__(self, *exc_info): | |
mc.undoInfo(closeChunk=True) | |
## This is how you call to the UndoContext() | |
with UndoContext(): | |
#... your code here.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment