• Fernanda

Making Control Curves with code

Updated: May 21


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


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.

149 views0 comments

Recent Posts

See All

Fernanda's Maya Shelf (updated 6/7/2021)

Below you'll find the Maya Shelf I've been using to make my workflow a bit faster. You should be able to download it, unzip it, then drag it into the Maya/20XX/prefs/shelves folder, and load it into M