PySide2 Undo/Redo inside Maya

Viewed 26

I have a question about PySide2 undo/redo in Maya. I read a discussions about using undoInfo Maya command but what if my GUI has to interact with many methods? How can I create an undo/redo for all of them at once instead of doing:

def method1():
    cmds.undoInfo(openChunk=True)
    # my code
    #
    cmds.undoInfo(closeChunk=True)

# or even
def method2():
    try
        cmds.undoInfo(openChunk=True)
        # my code
        #
    except:
        pass
    finally:
        cmds.undoInfo(closeChunk=True)
        
def method3():
    cmds.undoInfo(openChunk=True)
    # my code
    #
    cmds.undoInfo(closeChunk=True)

I want this:

cmds.undoInfo(openChunk=True)
def method1()
def method2()
def method3()
cmds.undoInfo(closeChunk=True)

Knowing that each method is connected to a button on the GUI

0 Answers
Related