Saturday, 27 May 2017

Maya channelBox in-line math operations

I wanted to make a post about this common technique, that not every TD in Maya knows. Especially the new ones who maybe switched from XSI or 3ds max.

How can make relative proportional change of one attribute value for multiple selected objects in Channel Box.

Imagine you have bunch of locators on one side, all different position, and you want to make duplicated locators on opposite side across some axis, let`s say world X.
So you duplicate them first and with the duplicated locators selected, you can now click select the TranslateX channel number field ( make sure its the number field, not the name) and now type:


This simple formula will multiply each selected locator TranslateX value. And the effect will be moving them to the opposite side.

You can read more here at this post by Asephei.

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') )