Animation control

Coded during lecture so probably a few kinks left to work out :) Creates a zeroed out animationcontroller. Select desired joint followed by control shape.

#
# Align a selected controler to a joint and 
# zero out the control
#

import maya.cmds as mc

sel = mc.ls(sl=1)

#align control object to joint
objParent = sel[0]
objChild = sel[1]
objConstraint = mc.parentConstraint(objParent, objChild)
mc.delete(objConstraint)


#select control
sel = mc.ls(sl=1)

#duplicate selected control
mc.duplicate(sel[1],n=sel[0] + "_NUL")

#remove shapenode
emptyNode = mc.delete(mc.ls(sl=1,s=1, dag=1))

#add original controller under newly created node
mc.parent(objChild, emptyNode) 

#rename control curve
mc.rename(objParent+"_CTRL", ignoreShape=1)
I wish to do something Great and Wonderful, but I must start by doing the little things like they were Great and Wonderful”
~ Albert Einstein