- results = []…what format goes in there? What do you mean to hold all the joints made?
- range (how many): isn’t the format usually something like, rang (start, end):but numbers (0,5) for example or can it be a single number that is -1 from what the user gives?
- so new_joint will generate a joint @ 0=x, j=y, z=0?
- if May will parent to the last automatically, then what’s the results.append(new_joint) for?
- what’s the return results do?
- why print make_joints(10), why 10?
result = []
this just makes an empty list, so you have a place to store the results. Just making things happen is rarely what you want to do - you’ll want to be able to chain things together and so each piece needs to tell the others what it’s doing
range with one argument starts at 0, and in this case that’s what we need.
new_joint doesn’t exactly generate the joint, it’s the result of the command “joint”. But yes, it holds the name of the new joint that gets created by the command. Here we are only hanging on to it long enough to add it to the result list but in a more complicated script we could do other things knowing what joint we had just made
results.append(new_joint)
adds the name of the new joint to the output list. The parenting behavior comes from Maya – by default whenever you make a joint it will be auto-parented to the last selected joint if there is one .
return results
sends the list of results back to whoever called the def. In this case it’s not really necessary – but you could have a second def that called this one and needed to know which joints had been created. All the built in maya commands work the same way – when the script calls cmds.joint() it is getting a return value which is the name of the joint.
and 10 is just an example: you can put any number you want in there. If you wanted to ask the user for a number you would do something like @capper’s example, which asks the user for a number and then passes it in place of the 10 in the example.