It's amazing that every so often, you realize you can streamline certain processes in Maya. I've come up with two handy functions you can run to perform tasks that usually take upwards to 5-10 minutes. Here's a couple I've just come up with.

Create Me Here

Creating stuff at 0,0,0 and moving it to a location, then parenting it is sometimes a drag, so why not automatically do it all at once?

import maya.cmds as cmds # if you haven't already

def cHere(thingToMake,p=True): # takes a type of thing to make and positions it at where the selected thing is, and parent it if p=True
    thingUMade = ""
    cmdsStr = "thingUMade = cmds."
    selected =
    pos = cmds.xform(selected, q=1, t=1, ws=1)
    exec(cmdsStr + thingToMake + "()")
    cmds.xform(thingUMade, t=pos, ws=1)
    if p:
        cmds.parent(thingUMade, selected)

Enable this function by copy/pasting it into Maya's Python script editor, then run it.

Then, say, you want to place a locator somewhere in your scene, and you've got the spot selected. Say, I also want to parent that locator under whatever I have selected. I simply run:


Voila. Substitute "spaceLocator" for your favourite maya cmd, "polySphere" "nurbsSphere" whatever you wish!

This script is utilizing a built-in function called exec() in Python, which takes a string of text and executes it as a python command. 

Argument About Default Value
thingToMake Specify a type of object that maya can make from command-line.
Eg: "spaceLocator", "polySphere", "nurbsSphere"...
"String" Type
None: Must Specify
p Parent
Allow the newly created object to be parented to the selected object.
Boolean (0 or 1 || True or False) Type
1 (True)

Quick Multiply/Divide Node

Want to quickly set up a multiplyDivide node relationship between two selected nodes? Know what attributes you want to use? Great! Because this one does all the hard connections work and setting up for you:

import maya.cmds as cmds #if you haven't already

def mdMe(outAtt, inAtt="", op=1, val2="1,1,1", axs="XYZ"): # sets up a MultiplyDivide node relationship between two selected elements, then we can set the xyz2 to a value
    if inAtt == "":
        inAtt = outAtt
    axis = [x.upper() for x in axs]
    xyz2 = [float(x) for x in val2.split(",")]
    selected =
    mdNode = cmds.createNode("multiplyDivide", n="{0}__{1}_MD".format(selected[0], selected[1]))
    num = 0
    for a in axis:
        cmds.setAttr(mdNode + ".input2" + a, xyz2[num])
        cmds.setAttr(mdNode + ".operation", op)
        num += 1
        cmds.connectAttr(selected[0] + "." + outAtt + a, mdNode + ".input1" + a)
        cmds.connectAttr(mdNode + ".output" + a, selected[1] + "." + inAtt + a )

Like the example above, run this in the Maya Python script editor to enable it.

Now I say I have "widget 1" and "widget 2" selected. (I selected "widget 1" first), and I want the rotate XYZ values from widget 1 to be multiplied by "2" and then plugged into "widget 2"'s rotate XYZ values.

mdMe("rotate", "rotate", op=1, xyz2="2,2,2", axs="XYZ")

mdMe("rotate", xyz2="2,2,2", axs="XYZ")

This will set up that connection easily.  Note that in the second line I've omitted the second rotate, and the operation arguments, this is because I have set up the function to see if a second attribute was set, if not, it will assume that you want rotates to be related on both selected nodes. You can omit any of the keyword arguments if you want just the default values.

Argument About Default Value
outAtt Attribute of the driver node . (Eg. "translate", "rotate", "scale"...)
"String" Type
None: Must Specify
inAtt Attribute of the driven node .
Attribute Name: "Translate", "rotate", "scale"...
"String" Type
None - If "", it will use the outAttr value
op Operation of the MultiplyDivide node.
1 = Multiply, 2= Divide
"String" Type
1 - Multiply
val2 The second value of the MD node.
Comma deliniated list of values.
"String" Type
axs The axis to connect the values with.
Comma deliniated list of axis.
Values have to be known axis.
"String" Type