Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Maya: Subdivide Joints
import maya.cmds as cmds
'''
Split joint chain between 2 joints (parent/child).
Usage Example:
jnts = cmds.ls(selection=True, type='joint')
subdivide_joints(jnts[0], jnts[1], 4)
'''
def subdivide_joints (jointA, jointB, segments=2):
newJnts = [jointA]
dist = cmds.getAttr('{}.tx'.format(jointB)) / segments
for i in xrange(1, segments):
newJnt = cmds.duplicate(jointA, po=True)[0]
if len(newJnts):
cmds.parent(newJnt, newJnts[-1])
cmds.setAttr('{}.tx'.format(newJnt), dist)
else:
cmds.parent(newJnt, jointA)
newJnts.append(newJnt)
cmds.parent(jointB, newJnts[-1])
return newJnts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.