maya duplicating and parenting joints by python not working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm creating multiple joints by code in maya, this is what I want to do. Create, and parent them like this...
L_Arm_00IK parent of L_Arm01IK parent of L_Arm02IK
L_Arm_00FK parent of L_Arm01FK parent of L_Arm02FK
L_Arm_00IKDriver parent of L_Arm01IKDriver parent of L_Arm02IKDriver
L_Arm_00Blend parent of L_Arm01Blend parent of L_Arm02Blend
but when I run my code, the First joints are created L_Arm_00IK, L_Arm_00FK, L_Arm_00IKDriver, L_Arm_00Blend
but their children aren't created. What am I doing wrong?
Below is the code.
def ikfkchain(name, side, parent, joints, fktemplate, iktemplate, pvtemplate, fkcolor, ikcolor):
fk_joints = duplicate_chain(joints, None, "_JNT", "Fk_JNT")
ik_joints = duplicate_chain(joints, None, "_JNT", "Ik_JNT")
ik_driver_joints = duplicate_chain(joints, None, "_JNT", "IkDriver_JNT")
blend_joints = duplicate_chain(joints, None, "_JNT", "Blend_JNT")
def duplicate_chain(joints, parent, replace_what, replace_with):
new_joints = []
new_joints_parent = parent
for jnt in joints:
new_jnt = cmds.duplicate(jnt, n=jnt.replace(replace_what, replace_with), po=True)[0]
if new_joints_parent:
cmds.parent(new_jnt, new_joints_parent)
new_joints_parent = new_jnt
new_joints.append(new_jnt)
return new_joints