def mel_handler(self, input_str): prev_chunk = cmds.undoInfo(q=True, chunkName=True) cmds.undoInfo(openChunk=True) try: execInMain(partial(mel.eval, input_str)) cmds.repeatLast(addCommand=input_str) cmds.undoInfo(closeChunk=True) except: cmds.undoInfo(closeChunk=True) if not cmds.undoInfo(q=True, chunkName=True) == prev_chunk: cmds.undo() raise
def py_handler(self, input_str): prev_chunk = cmds.undoInfo(q=True, chunkName=True) cmds.undoInfo(openChunk=True) try: execInMain(input_str) setattr(__main__, "last_py_cmd", input_str) cmds.repeatLast(addCommand='python("execInMain(last_py_cmd)")') cmds.undoInfo(closeChunk=True) except: cmds.undoInfo(closeChunk=True) if not cmds.undoInfo(q=True, chunkName=True) == prev_chunk: cmds.undo() raise