Thursday, 18 May 2017

Maya python UI passing argument in command

Here is example of Maya UI code in case you need to build in a command to UI element which passes an argument.
More about this technique here:

Note - this is all one function myUI(), where buttonPressed is function defined inside that function. It doesn`t have to be, but this way it is localised and only visible to the UI function.

import maya.cmds as mc

def myUI():

    def buttonPressed(name):
        print "pressed %s!" % name

    win = mc.window(title="My Window")
    layout = mc.columnLayout()
    btn = mc.button( command = lambda *args: buttonPressed('chad') )


Saturday, 14 January 2017

Maya 2017 Pose Editor script tweak

If you worked with Pose Editor in Maya 2017 there is a chance you got an error when using Add Pose function.

In case your mesh shape was the same like its transform parent. For example transform: "body_geo" has shape: "body_geo". Maya will get clashing name problem when using duplicated shape which gets created for Pose Shape. Because duplicate command does not return long names.

If you want to prevent this to happen, just edit the duplicate command in file:


add -rc flag to duplicate command on line 19 like this:

string $copyMesh[] = `duplicate -rc $longName`;

This is renameChildren flag which makes sure that new DAG nodes will have unique names. The whole edited file is also available for download on this link: