I just learned from a Stack Overflow post that
print (Len())
returns None. So you have to modify it to print a value such as follows
children = [1,2,3]
numChild = len(children)
print (numChild)
However, this does not work on my script. The script below creates a curve based on a joint chain. The script works. No errors. My question here is purely speculative.
I have 3 joints in a chain selected. It should return a value of 2. However, when I try to execute the print len command, it runs 0 or none.
Is there something I am missing out?
children=[]
def joint_positions(j):
pos = [cmds.xform(j,q=True, t=True, ws=True)]
children = cmds.listRelatives(j, c=True) or []
for child in children:
pos.extend(joint_positions(child))
return pos
numChild = len(children)
print (numChild) #this line prints out zero. it should print out 2
joints = joint_positions('spine01_jnt')
crv = cmds.curve(d = 1, p=joints)
cmds.rebuildCurve( crv, rt=0, s=len(children), d=3 )
The code above is modified from a post in Stack Overflow
Thank you for looking at the problem