Feb 272013

I will be adding actual code under this category … be warned, even though i will try to invent a new wheel, it will take some time probably :). You can grab the script at the end of the post.

This type of script exist for like forever, the only different thing is that ive used vectors to do it, mainly subtraction and scaling of vectors:

`#get the joints positions and convert to MVectors strJntRaw = cmds.xform(startJnt,ws=True,q=True,t=True) strJntPos = om.MVector(strJntRaw[0], strJntRaw[1], strJntRaw[2])`

`endJntRaw = cmds.xform(jntChild[0],ws=True,q=True,t=True) endJntPos = om.MVector(endJntRaw[0], endJntRaw[1], endJntRaw[2])`

`#subtracting vectors in order to get to the segments position subJnt = endJntPos - strJntPos`

`for i in range(1,int(numSegments)): newJntPos = subJnt * i * (1/numSegments) + strJntPos`

Also, Ive tried to check for the proper orient rotation ( aka the child joint was not moved with Insert and has translation in only one axis) using vectors, specifically getting the norm vector of the child and checking to see if it has 1 on one of the axis. This is done in local space ( it would not work in world).

`endJntRaw = cmds.xform(endJoint,q=True,t=True) endJntPos = om.MVector(endJntRaw[0], endJntRaw[1], endJntRaw[2]) downAxis = '' endJntNorm = endJntPos.normal() for i in range(0,3):`

`if endJntNorm[i] == 1: if i==0: downAxis = 'x' print 'its x' elif i==1: downAxis = 'y' print 'its y' elif i==2: downAxis = 'z' print 'its z' return downAxis`

Download bdSplitJoint.py