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 cmdsimport myTool
myTool.install()
cmds.myTool()# "Doing!"# (press z)# "Undoing.."

*myTool.py*

from maya import cmdsfrom 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.

On Sat, 11 Aug 2018 at 00:36, likage <dissidia....@gmail.com> wrote:

> I have run a custom tool in a maya scene.
> Say, if I am going to perform `z` (undo) via the keyboard, I would want to
> set the evaluation mode to be 'off' if the previous action is/ belongs to
> my custom tool.
>
> I tried using `cmds.scriptJob(listJobs=True)`, while the entire contents
> are somewhat similar, before/ after using the undo key, with the exception
> of the last line, I am unable to script in a proper manner that will sets
> off the evaluation mode.
>
> What any other ways can I proceed with this?
>
> --
> 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_maya+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/cd3aa750-fb11-4eb8-a5a3-3a7ab3225b2d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA6yo4RtyvNPjXTHJ%3DA43qVo9Wh398YhRrwoXDbyA_UCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to