• Fernanda

Making Control Curves with code

Intro

This will be the first in (what I hope to be) a recurring series of posts on python tutorials for rigging. That being said, this is just my own personal approach; I'm always open to feedback, and I love to learn more than one way to do something. Message me if you got anything! (Also if you run into any problems with the code let me know)


In this tutorial you will learn how to make control curves for rigging. These curves are compensated through a node that sets their transforms to zero. That way the animators won't go insane if they want to put them back in their original position; it makes the overall rig experience cleaner for everybody.


I believe coding something is easier when you learn how to do it manually first, so please take a look at this slightly awkward tutorial I made on it:




Code Sample #1

Behold:

This short script is basically what we did manually translated into code. It gets the currently selected curve, assigns it to a variable ctrl, duplicates it, parents the duplicate to the original's shape node and deletes said shape node.


Notice the [0] added at the end of the ls command. The ls command usually returns a list of objects, and we want the first item of that list, which should be selected curve.

But what if we want to perform the operation on multiple curves at the same time? How can we make this work while having more than one curve selected?


Code Sample #2

The answer is very simple! We'll go ahead and treat the variable ctrl as a list (removing the [0]), and have a for loop go perform the operation for all the items in the list.

But now we're faced with the possibility of the user having other types of things selected such as joints. Since we have no interest in creating compensate nodes for joints, we need to add a condition that takes care of that if it does happen.


Code Sample #3

In this case, the condition can me a simple if statement that ignores the node if it's not a transform.

Try running it with a joint selected! I dare you.


In Conclusion

I hope you liked this tutorial! I'm still getting used to the idea of making tutorials since I'm learning a lot myself, but it was a great refresher for me and I'd love to make more in the near future. I'll be covering very simple concepts in the beginning and hopefully they'll evolve into more complex topics such as auto-riggers and exporting tools.




136 views

Recent Posts

See All

AutoRigger Showcase | Leg Module

Missed the Arm Module? Check it out! Here's the leg portion of the autorigger. Not much to talk about on this one since the arm and leg modules share a lot of methods. That's the great thing about div