Hi all,

I’m looking to integrate undo into a series of commands made via the API.

from maya.api import OpenMaya as om

mod = om.MDagModifier()
mod.createNode("transform")
mod.doIt()

Maya is very kind to include the mod.undoIt() command, but it doesn’t enjoy
calling it when being asked to Undo, such as via the Edit -> Undo menu item.

Google revealed that this topic has been discussed quite
<http://forums.cgsociety.org/archive/index.php?t-1135833.html> a
<https://groups.google.com/forum/#!topic/python_inside_maya/xN9MoGumJxQ> few
<https://stackoverflow.com/questions/37263151/how-to-undo-deleting-meshes-using-the-maya-api>
times
<http://around-the-corner.typepad.com/adn/2012/07/looking-at-undo-in-regards-to-deleting-attributes-and-nodes.html>
in the past with little to no avail.. The suggested methods seem to boil
down to either..

   1. Don’t use the API
   2. Write a Command Plug-in

Let’s assume for a second that (1) is a no-go, then what about (2)? That
would work in situations where you had a pre-defined command you needed to
run multiple times in a pre-defined fashion; like the cmds.polySphere
command that creates a few nodes, makes a few connections and sets a few
attributes.

But what if you just wanted to run something like the above? What if the
number of commands you had in mind are many, or depend on too many factors
to embed into a plug-in? Is there no hope?

What I’m hoping for is something along these lines..

queue = om.MGlobalUndoQueue()
queue.append(mod.undoIt)

Such that when the user attempts to undo, this command is called, followed
by whatever else was in the queue at the time of appending.

It doesn’t have to be this of course. So long as I tailor what is going to
be undone when undo is on the march.

Any ideas?
​

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBAXFYkxwksT03x42s9U_tt5XjV%2BXXS_oHhntui9yKVHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to