Challenging!
I would want to set the evaluation mode to be ‘off’ if the previous action is/ belongs to my custom tool.
If you want to perform a specific command on undo, you could implement your tool as a Maya Command.
from maya import cmds
import myTool
myTool.install()
cmds.myTool()
# "Doing!"
# (press z)
# "Undoing.."
myTool.py
from maya import cmds
from maya.api import OpenMaya as om
class MyTool(om.MPxCommand):
def doIt(self, args):
print("Doing!")
def undoIt(self):
print("Undoing..")
def redoIt(self):
print("Redoing!")
def isUndoable(self):
# Without this, the above undoIt and redoIt will not be called
return True
maya_useNewAPI = True
def initializePlugin(plugin):
om.MFnPlugin(plugin).registerCommand("myTool", MyTool)
def uninitializePlugin(plugin):
om.MFnPlugin(plugin).deregisterCommand("myTool")
def install():
# Load command on `import myTool`
cmds.loadPlugin(__file__)
If you put e.g. cmds.evaluationManager(mode="off") in the undoIt method, then whenever you undo this particular command, it’ll turn off (which is another word for DG) the evaluation manager.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/cd3aa750-fb11-4eb8-a5a3-3a7ab3225b2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.