#make a leg! def SetUpLeg(prefix): #make maya commands available import maya.cmds as mc #set up IK #ankle IK mc.ikHandle(n=prefix + 'legIKHandle', sj=prefix + 'hip', ee=prefix + 'ankle', sol='ikRPsolver') #mc.poleVectorConstraint(prefix + 'kneeControl', prefix + 'legIKHandle') #ball IK mc.ikHandle(n=prefix + 'ballIKHandle', sj=prefix + 'ankle', ee=prefix + 'ball', sol='ikSCsolver') #toe IK mc.ikHandle(n=prefix + 'toeIKHandle', sj=prefix + 'ball', ee=prefix + 'toe', sol='ikSCsolver') #create empty groups and move their pivots to the correct locations mc.group(em=True, w=True, n=prefix + 'liftHeelPivot') c = mc.pointConstraint(prefix + 'ball',prefix + 'liftHeelPivot') #position the group at the correct joint mc.delete(c) #delete the constraint after it's placed the pivot mc.group(em=True, w=True, n=prefix + 'toeTapPivot') c = mc.pointConstraint(prefix + 'ball',prefix + 'toeTapPivot') mc.delete(c) mc.group(em=True, w=True, n=prefix + 'tipToePivot') c = mc.pointConstraint(prefix + 'toe',prefix + 'tipToePivot') mc.delete(c) mc.group(em=True, w=True, n=prefix + 'swivelPivot') c = mc.pointConstraint(prefix + 'ball',prefix + 'swivelPivot') mc.delete(c) mc.group(em=True, w=True, n=prefix + 'anklePivot') c = mc.pointConstraint(prefix + 'ball',prefix + 'anklePivot') mc.delete(c) mc.group(em=True, w=True, n=prefix + 'anklePivotOffset') c = mc.pointConstraint(prefix + 'ball',prefix + 'anklePivotOffset') mc.delete(c) #setup group hierarchy mc.parent(prefix + 'legIKHandle', prefix + 'liftHeelPivot') mc.parent(prefix + 'toeIKHandle', prefix + 'toeTapPivot') mc.parent(prefix + 'ballIKHandle', prefix + 'toeTapPivot') mc.parent(prefix + 'toeTapPivot', prefix + 'tipToePivot') mc.parent(prefix + 'liftHeelPivot', prefix + 'tipToePivot') mc.parent(prefix + 'tipToePivot', prefix + 'swivelPivot') mc.parent(prefix + 'swivelPivot', prefix + 'anklePivot') mc.parent(prefix + 'anklePivot', prefix + 'anklePivotOffset') #setup knee control mc.poleVectorConstraint(prefix + 'kneeControl', prefix + 'legIKHandle') #parent (constraint) foot control to leg groups mc.parentConstraint(prefix + 'footControl', prefix + 'anklePivotOffset') #add attributes to foot control mc.select(prefix + 'footControl') mc.addAttr(k=True, ln='ToeTap') mc.addAttr(k=True, ln='TipToe') mc.addAttr(k=True, ln='Ankle') mc.addAttr(k=True, ln='Swivel')