workflow

Python rigging tools

Hey yall, I’ve been working on a couple quick little python scripts to speed up some basic maya rigging steps. I wrote them in python instead of mel, but now wish i had written them in pymel instead. what a crazy world this whole maya scripting thing is. anyway i’m gonna start posting some, feel free to take them, would you kindly  just leave my name on them 😀

duplicate and rename a hierarchy. useful for quickly creating multiple skeletons for IK/FK switches. the raw data popup is asking for a suffix to append to the name of the objects


#==Script by Steve Pettit==#
import maya.cmds as cmds
suffix = raw_input("Enter a suffix: ")
cmds.select(hi=1)
selection = cmds.ls(sl = True)
cmds.duplicate(selection[0], n = selection[0] + suffix)
cmds.select(selection[0] + suffix, hi=1)
dupSelection = cmds.ls(sl = True)
relSel = cmds.listRelatives(dupSelection, children = True)
curParent = selection[0] + suffix
for i in relSel:
curSel = relSel[relSel.index(i)]
cmds.rename(curParent + '|' + curSel, curSel+ suffix)
curParent = curParent + '|' + curSel + suffix + '|'

these ones will create controls for fingers that make them curl when rotated down the finger chain

#==Script by Steve Pettit==#
#==R_fingers==#
hiSelection = cmds.select(hi = 1)
selection = cmds.ls(sl = True)
fingerCtrl = cmds.curve(d=1, p=[(0,0,0),(0,3,0),(0,4,-1),(0,5,0),(0,4,1),(0,3,0)], k=[1,2,3,4,5,6])
cmds.pointConstraint(fingerCtrl, selection[0])
mult = cmds.createNode('multiplyDivide', n='myNode')
cmds.connectAttr(fingerCtrl+'.rz','myNode.input1X')
cmds.setAttr('myNode.input2X', -1)
cmds.connectAttr('myNode.outputX', selection[0]+'.rz')
cmds.connectAttr('myNode.outputX', selection[1]+'.rz')
cmds.connectAttr('myNode.outputX', selection[2]+'.rz')
#==L_fingers==#
hiSelection = cmds.select(hi = 1)
selection = cmds.ls(sl = True)
fingerCtrl = cmds.curve(d=1, p=[(0,0,0),(0,3,0),(0,4,-1),(0,5,0),(0,4,1),(0,3,0)], k=[1,2,3,4,5,6])
cmds.pointConstraint(fingerCtrl, selection[0])
cmds.connectAttr(fingerCtrl+'.rz', selection[0]+'.rz')
cmds.connectAttr(fingerCtrl+'.rz', selection[1]+'.rz')
cmds.connectAttr(fingerCtrl+'.rz', selection[2]+'.rz')

that’s all for now friends. more later