def jointFromList(xformList=[], orient="xyz", secAxis="zup", strip="", suffix="", *args):
"""
uses the xformlist arg (a list of transforms in scene) to create a joint chain in order.
Arguments: xformList (a list), orient ("xyz", etc), secAxis ("xup", "zdown", etc), strip (string to strip off), suffix (string to add to the joints)
"""
jointList = []
#if no list is provided, get the list from selection order
if not xformList:
sel = getSelection()
if sel:
xformList = sel
#if no list && no selection then throw error
else:
cmds.error("you must provide a list of transforms or have the transforms selected in order")
#clear selection
cmds.select(cl=True)
#for each thing in the list create a joint at that location (they'll be parented to the previous)
for xform in xformList:
xformPos = cmds.xform(xform, q=True, ws=True, t=True)
jointName = "%s%s"%(xform.rstrip(strip), suffix)
thisJoint = cmds.joint(n=jointName, p=xformPos)
jointList.append(thisJoint)
#now orient the joint chain based on args and return a list of the joints
cmds.joint(jointList[0], e=True, ch=True, oj=orient, sao=secAxis)
return(jointList)
评论列表
文章目录