Python maya.cmds 模块,undoInfo() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用maya.cmds.undoInfo()

项目:mgear    作者:miquelcampos    | 项目源码 | 文件源码
def one_undo(func):
    """Decorator - guarantee close chunk.

    type: (function) -> function

    """
    @wraps(func)
    def wrap(*args, **kwargs):
        # type: (*str, **str) -> None

        try:
            cmds.undoInfo(openChunk=True)
            return func(*args, **kwargs)

        except Exception as e:
            raise e

        finally:
            cmds.undoInfo(closeChunk=True)

    return wrap
项目:maya-pulse    作者:bohdon    | 项目源码 | 文件源码
def buttonCommand(func, *args, **kwargs):
    """
    Return a function that can be called which will execute
    the given function with proper undo chunk handling.
    """

    def wrapper():
        cmds.undoInfo(openChunk=True)
        try:
            func(*args, **kwargs)
        except Exception as e:
            print(e)
        finally:
            cmds.undoInfo(closeChunk=True)

    return wrapper
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def undo(function):
    '''A decorator that will make commands undoable in maya'''

    def decoratorCode(*args, **kwargs):
        cmds.undoInfo(openChunk=True)
        functionReturn = None
        try:
            functionReturn = function(*args, **kwargs)
        except:
            print sys.exc_info()[1]
        finally:
            cmds.undoInfo(closeChunk=True)
            cmds.undoInfo(printQueue=True)
            return functionReturn

    return decoratorCode
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def undoable(function):
    '''A decorator that will make commands undoable in maya'''

    def decoratorCode(*args, **kwargs):
        cmds.undoInfo(openChunk=True)
        functionReturn = None
        try: 
            functionReturn = function(*args, **kwargs)

        except:
            print sys.exc_info()[1]

        finally:
            cmds.undoInfo(closeChunk=True)
            return functionReturn

    return decoratorCode
项目:maya-capture-gui    作者:Colorbleed    | 项目源码 | 文件源码
def no_undo():
    """Disable undo during the context"""
    try:
        cmds.undoInfo(stateWithoutFlush=False)
        yield
    finally:
        cmds.undoInfo(stateWithoutFlush=True)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def __enter__(self):
        if self.result == 0:
            cmds.undoInfo(stateWithoutFlush=0)
        else:
            cmds.undoInfo(openChunk=1)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def __exit__(self, *exc_info):
        if self.result == 0:
            cmds.undoInfo(stateWithoutFlush=1)
        else:
            cmds.undoInfo(closeChunk=1)


# -------------------------------------------------------------------------------- #

# RPARTIAL() : Subclass of partial used instead to set maya's Undo/Redo output appropriately
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def press(self, *args):
        '''
        Be careful overwriting the press method in child classes, because of the undoInfo openChunk
        '''

        self.anchorPoint = mc.draggerContext(self.draggerContext, query=True, anchorPoint=True)
        self.button = mc.draggerContext(self.draggerContext, query=True, button=True)

        # This turns off the undo queue until we're done dragging, so we can undo it.
        mc.undoInfo(openChunk=True)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def release(self, *args):
        '''
        Be careful overwriting the release method in child classes. Not closing the undo chunk leaves maya in a sorry state.
        '''
        # close undo chunk and turn cycle check back on
        mc.undoInfo(closeChunk=True)
        #mc.cycleCheck(evaluation=self.cycleCheck)
        mm.eval('SelectTool')
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def __enter__(self):
        '''
        Turn off undo
        '''
        mc.undoInfo(stateWithoutFlush=False)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def __exit__(self,*args):
        '''
        Turn on undo
        '''
        mc.undoInfo(stateWithoutFlush=True)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def __enter__(self):
        '''open the undo chunk'''
        if self.force or MAYA_VERSION < 2011:
            self.force = True
            mc.undoInfo(openChunk=True)