finger improvements

a while back i posted some python auto finger rig thing. turns out that was garbage! the good news is this one isn’t as much garbage! select the top most knuckle joint of a simple 3 joint finger (not including end joint) run this in your script editor and boom! auto curl, spread, and individual knuckle bends. works on mirrored joints too. i think. let me know if it doesn’t

import maya.cmds as cmds
hiSel =
selection = = True)
cmds.setAttr(selection[0]+'.jointOrientX', 0)
cmds.setAttr(selection[0]+'.jointOrientY', 0)
cmds.setAttr(selection[0]+'.jointOrientZ', 0)
topJointWS = cmds.xform(selection[0], q = True, ws = True, rp =True)
midJointWS = cmds.xform(selection[1], q = True, ws = True, rp =True)
btmJointWS = cmds.xform(selection[2], q = True, ws = True, rp =True)
topNull =[0], n = 'topNull')
midNull =[1], n = 'midNull')
btmNull =[2], n = 'btmNull')
cmds.move(topJointWS[0],topJointWS[1],topJointWS[2], topNull+'.rotatePivot', topNull+'.scalePivot')
cmds.move(midJointWS[0],midJointWS[1],midJointWS[2], midNull+'.rotatePivot', midNull+'.scalePivot')
cmds.move(btmJointWS[0],btmJointWS[1],btmJointWS[2], btmNull+'.rotatePivot', btmNull+'.scalePivot')
#add controller to top and give it bend attrs
myCtrlName = selection[0]+'_curl'
fingerCtrl = cmds.curve(d=1, p=[(0,0,0),(0,1.5,0),(0,2,-0.5),(0,2.5,0),(0,2,0.5),(0,1.5,0)], k=[1,2,3,4,5,6], n = myCtrlName)
cmds.parent(fingerCtrl, selection[0], relative = True)
cmds.parent(fingerCtrl, w = True)
#lock and hide attrs
cmds.setAttr(fingerCtrl+'.translate', lock=True, k = False, cb= False)
cmds.setAttr(fingerCtrl+'.scale', lock=True, k = False, cb= False)
cmds.addAttr(fingerCtrl, at='float', ln='topBend', k = True)
cmds.addAttr(fingerCtrl, at='float', ln='midBend', k = True)
cmds.addAttr(fingerCtrl, at='float', ln='bottomBend', k = True)

#connect bend attrs to the joints
cmds.connectAttr(fingerCtrl+’.topBend’, selection[0]+’.rz’)
cmds.connectAttr(fingerCtrl+’.midBend’, selection[1]+’.rz’)
cmds.connectAttr(fingerCtrl+’.bottomBend’, selection[2]+’.rz’)
cmds.connectAttr(fingerCtrl+’.ry’, selection[0]+’.ry’)
#make SDKs on the nulls for the curl

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: ")
selection = = True)
cmds.duplicate(selection[0], n = selection[0] + suffix)[0] + suffix, hi=1)
dupSelection = = 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==#
hiSelection = = 1)
selection = = 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.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')
hiSelection = = 1)
selection = = 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