--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
-----
import maya
maya.cmds.SimpleCommand()
-----
However, when I put some code in front of the script call, undo does
not work anymore. I suspect it might have something to do with this
being API code and not MEL, thus perhaps tunneling below the undo-
queue.
Does someone know this for certain? Thanks for a quick hint, here is
the script code which prevents the undo of SimpleCommand() to be
triggered:
-----
import maya
import maya.OpenMaya as api
#New Scene
api.MGlobal.executeCommand('file -new -f')
#Create and fetch three tori
oCmdResult = api.MCommandResult()
aCmdResult = []
api.MGlobal.executeCommand('polyTorus -name Pong1', oCmdResult)
oCmdResult.getResult(aCmdResult)
sTorus0 = aCmdResult[0]
api.MGlobal.executeCommand('polyTorus -name Pong2', oCmdResult)
oCmdResult.getResult(aCmdResult)
sTorus1 = aCmdResult[0]
api.MGlobal.executeCommand('polyTorus -name Pong3', oCmdResult)
oCmdResult.getResult(aCmdResult)
sTorus2 = aCmdResult[0]
api.MGlobal.executeCommand('move 0 5 0 %s' %(sTorus1))
api.MGlobal.executeCommand('rotate 0 45 45 %s' %(sTorus1))
api.MGlobal.executeCommand('move 0 10 0 %s' %(sTorus2))
#Call the command
maya.cmds.SimpleCommand()
-----
Cheers!
-André
On Nov 18, 11:55 am, jo benayoun <jobenay...@gmail.com> wrote:
> Hi André,
>
> Have you try to put a trace statement ("print ...") inside your
> "isUndoable()" method to see if Maya queries it right after the command's
> execution ?
> Do you make a use of Maya Python API calls during the execution of your
> commands which are not undoable or modify underlying datas ?
> Have you check for typos ? :(
>
> jo
>
> 2011/11/18 André Adam <a_adam_li...@gmx.de>
import os
import maya.cmds as mc
def pluginLoader(load):
fullPath = __file__
if fullPath.endswith('.pyc'):
fullPath = fullPath [:-1]
dirPath, plugin = os.path.split(fullPath)
if load:
if not mc.pluginInfo(plugin, query=True, loaded=True):
mc.loadPlugin(fullPath, quiet=True)
mc.pluginInfo(plugin, edit=True, autoload=True)
else:
if mc.pluginInfo(plugin, query=True, loaded=True):
mc.unloadPlugin(plugin, force=True)
mc.pluginInfo(plugin, edit=True, autoload=False)
Then in the script editor I do something like this, which I can
highlight and execute as a single block:
import myPlugin
myPlugin.pluginLoader(False)
reload(myPlugin)
myPlugin.pluginLoader(True)
# Now execute the plugin code
# ...
I've also read it's a really good idea to flush your undo queue when
unloading\reloading the plugin.
Your code looks like a good wrapper for working with plugins, thanks
for sharing!
-André