Updated
This commit is contained in:
17
Scripts/Modeling/Edit/CreasePlus/MayaUndoRun.py
Normal file
17
Scripts/Modeling/Edit/CreasePlus/MayaUndoRun.py
Normal file
@ -0,0 +1,17 @@
|
||||
from functools import wraps
|
||||
import maya.cmds as cmds
|
||||
|
||||
def mayaUndoRun(func):
|
||||
""" Puts the wrapped `func` into a single Maya Undo action, then
|
||||
undoes it when the function enters the finally: block """
|
||||
@wraps(func)
|
||||
def _undofunc(*args, **kwargs):
|
||||
try:
|
||||
# start an undo chunk
|
||||
cmds.undoInfo(openChunk=True)
|
||||
return func(*args, **kwargs)
|
||||
finally:
|
||||
# after calling the func, end the undo chunk
|
||||
cmds.undoInfo(closeChunk=True)
|
||||
|
||||
return _undofunc
|
Reference in New Issue
Block a user