So here is a snipit of an IK spine builder I've been working on. I've figure out how to make lists to duplicate the bound into an IK chain, what I've got stuck on however is I want my list and for loop to parent constraint each joint in the bound hierarchy to it's corresponding joint in the ik hierarchy:
import maya.cmds as cmdsdef linkJointChain(lookFor='joint'):namePref = 'ct_'limbPref = 'spine'ctlName = namePref + limbPref#list selection to get the joint and their childrenroot = cmds.ls(sl=True)[0] # adding a zero bracket makes sure it counts the head of the herarchy toochild = cmds.listRelatives(root,ad=1,type='joint')child.append(root)child.reverse()limbJnt = childprint(child)#list all joints in chain, this list will be refrenced by all the commands beneath itroot = cmds.ls(sl=True)[0]child = cmds.listRelatives(root,ad=1,f=True,children=True,type='joint')#rename the jointsfor j, name in enumerate(child):cmds.rename(name,namePref + limbPref + 'AJ{0}_BIND_JNT'.format(len(child)-j))print(child)#rename beggining and end joints to start and end respectivlyroot = cmds.ls(sl=True)child = cmds.listRelatives(root,ad=1,f=True,children=True,type='joint')cmds.rename(child[0],ctlName +'AJ_BIND_END_JNT')cmds.rename(root,ctlName + 'AJ_BIND_START_JNT')#duplicate bound chain for ik spineroot = cmds.ls(sl=True)IKChain = cmds.duplicate(root,n=ctlName + 'AJ_IK_START_JNT')IKList = cmds.listRelatives(ctlName + 'AJ_IK_START_JNT', ad=True,pa=True)for IKn, name in enumerate(IKList):cmds.rename(name, ctlName +'AJ{0}_IK_JNT'.format(len(IKList)-IKn))print(IKList)#select IK chain, then,set joints size for easy grabbing on IK chaincmds.select(ctlName +'AJ_IK_START_JNT')IKRoot = cmds.ls(sl=True)[0] IKChild = cmds.listRelatives(ctlName +'AJ_IK_START_JNT', ad=True,pa=True)IKChild.append(IKRoot)for r in IKChild:cmds.setAttr(r + '.radius', 1.5)#parent constrain bound spine to ik spineikJntChain=cmds.listRelatives(ctlName +'AJ_IK_START_JNT',ad=1,type='joint')ikJntChain.append(ctlName +'AJ_IK_START_JNT') #try appending your other joint chain to create a double list with which to appendikJntChain.reverse()ikLimbJnt = ikJntChainboundJntChain=cmds.listRelatives(ctlName +'AJ_BIND_START_JNT',ad=1,type='joint')boundJntChain.append(ctlName +'AJ_BIND_START_JNT') #try appending your other joint chain to create a double list with which to appendboundJntChain.reverse()boundLimbJnt = boundJntChainlimbJnt = ikJntChain+boundJntChainprint(limbJnt)for j in limbJnt:spineCons = cmds.parentConstraint(ikJntChain[0],boundJntChain[0])#ikParChain = cmds.parentConstraint(j,ikJntChain)linkJointChain()
the script has hardcoded names for the listRelatives because the full script reads the joint chain and places controls at the start and end joint after renaming the first and last joints in the list, I know it has something to do with the brackets in cmds.parentConstraint