Hello everyone, I wrote a script that places joints on a curve in maya for a guy I worked with. He needed it for something he was working on. I wanted to know if I did this somewhat well, I’m just starting out making tools for maya so any guidance would be appreciated.
Thank you!
numberOfBones = TheNumberOfJointsPerCV
curveShape = cmds.ls(selection=True)
numberOfPoints = cmds.getAttr(str(curveShape[0]) + '.degree')
initialPointPos = cmds.pointOnCurve(curveShape, pr = 0.0)
initialJoint = cmds.joint(p =(initialPointPos[0], initialPointPos[1], initialPointPos[2]))
for i in range(0, numberOfPoints):
curvePointPosStart = cmds.pointOnCurve(curveShape, pr = i, cc = True)
curvePointPosEnd = cmds.pointOnCurve(curveShape, pr = i+1, cc = True)
initialJoint = cmds.joint(p =(curvePointPosStart[0], curvePointPosStart[1], curvePointPosStart[2]))
boneDistanceX = (curvePointPosEnd[0] - curvePointPosStart[0])/numberOfBones
boneDistanceZ = (curvePointPosEnd[2] - curvePointPosStart[2])/numberOfBones
cmds.select(initialJoint)
print "point: " + str(i)
for i in range (0, numberOfBones):
print i*boneDistanceX
cmds.joint(p =(i*boneDistanceX, 0.0, i*boneDistanceZ))
cmds.move(boneDistanceX, 0.0, boneDistanceZ, cmds.listRelatives(initialJoint, c = True), a=True, ls = True)