Keep up-to-date with Free tutorials!!


Sign up to our twice-monthly newsletter today for the latest tutorials, interviews and product information.

Sign me up to receive third-party emails from 3dtotal's partners, too!

- Latest news
- Exclusive Shop Offers
- Preview early content
- Plus much more


Not Ready to take that step? OK, Why not just Subscribe to the RSS Feed

submit tutorial
1 | 2 | 3
Using Driven Keys to create a handController

| Your Rating:
rating star nonerating star nonerating star nonerating star nonerating star none
(Score 0 out of 5 after 0 Votes)
| Comments 0
Date Added: 9th December 2009
Software used:

OK, the indexfinger is rigged. Now let's see if we can use the MEL to something useful here. But first a question for you:

- "If you want to edit the rotation value of "jIndex_base" when "handControl.index" has a value of 10, what do you do?

A) I open the "Set Driven Key" Window and key the joint one more time.
B) Easy, I just run one single line of MEL code.

If your answer was A, read on. If your answer was B, well then you already know the easier way to do this :)

Obviously Maya used the command "setDrivenKeyframe" to set Driven Keyframes. I looked it up in the Maya MEL command reference. (help > MEL command reference) and found out that the flags I have to use was -driverValue (-dv) and -value (-v). When you want to check if something works, use some insane values to see the changes. If you wonder if a light is behaving correctly with its intensity 1 boost it up to 100 or more to get a direct feedback. Here I don't have to go crazy to check because it will be very obvious that something changed. I am going to try and edit "jIndex_middle's" value when "nHandControl.index" has a value of "10". I write this line in my scriptEditor and run it:

setDrivenKeyframe -dv 10 -v -25 nHandControl.Index jIndex_middle.rotateZ;

I can see that it works when I slide the nHandControl.index value. And so can you on the image below. Compared to the image above you can clearly see that the angle on jIndex_middle no longer rotate all the -108.836 degrees,but -25 degrees.

Yes! A new era to rigging has begun :) Let's analyze what we just did and use it to rig the middle finger.

setDrivenKeyframe -cd nHandControl.Index jIndex_middle.rotateZ;

This is the sentence originally found in the script Editor.

  • "setDrivenKeyframe": Basicly the command that tells us that we are setting a driven key.
  • "-cd": Short for currentDriver. What this flag does is to tell Maya that she shall use the first stated object as the driver.
  • "nHandControl.Index jIndex_middle.rotateZ": Tells Maya to key the values of these two selected attributes.

But our editline did not look like that. The reason is because I don't want to depend on a selection. That's actually the whole point with this. Therefore I need a way to insert custom values. As you remember, my line looked like this:
setDrivenKeyframe -dv 10 -v -25 nHandControl.Index jIndex_middle.rotateZ;

When I looked up the command in the MEL command reference I noticed that the way you should set this up is setDrivenKeyframe (flags) (objects);

"setDrivenKeyframe": We should know what this does by now.
"-dv": short for driverValue. This is where we set the value of the driver.
"-v": Short for value. This is where we set the value of the driven
"-cd": Short for currentDriver.You state that nHandControl is the current driver.
"nHandControl.Index jIndex_middle.rotateZ": Then we list the driver first and then the driven.

With our clever brains we should be able to understand what to do next. nHandControl still runs the show and our next thing to rig will be the middle finger. The new lines of code will then be:

//This is to set the neutral position

setDrivenKeyframe -dv 0 -v 0 -cd nHandControl.Middle jMiddle_base.rotateZ;
setDrivenKeyframe -dv 0 -v 0 -cd nHandControl.Middle jMiddle_middle.rotateZ;
setDrivenKeyframe -dv 0 -v 0 -cd nHandControl.Middle jMiddle_top.rotateZ;

//This is to set the negative position

setDrivenKeyframe -dv -10-v 16.381 -cd nHandControl.Middle jMiddle_base.rotateZ;
setDrivenKeyframe -dv -10-v 15.998 -cd nHandControl.Middle jMiddle_middle.rotateZ;
setDrivenKeyframe -dv -10 -v 22.056 -cd nHandControl.Middle jMiddle_top.rotateZ;

//And this is to set the positive position (grip)

setDrivenKeyframe -dv 10-v -110.892 -cd nHandControl.Middle jMiddle_base.rotateZ;
setDrivenKeyframe -dv 10 -v -108.836 -cd nHandControl.Middle jMiddle_middle.rotateZ;
setDrivenKeyframe -dv 10 -v -81.881 -cd nHandControl.Middle jMiddle_top.rotateZ;

Obviously you don't need to include the flag -cd when editing, but the rig isn't affected by it anyway. So keep it there to use the script as both a creation and a possible edit chart.

Now, if you're smart you'll gather all these lines for all the fingers and put them in the same MEL file for later editing. Let's come up with a scenario again. Scenarios are fun :) You have rigged a monster with 10.000 fingers.... Of course you are told to correct this. The rotation of all the middle joints are set up at "100" and the animation supervisor wants it to be "130" because the animators don't feel they get freedom to exaggerate as I talked about earlier. Instead of banging your head against the wall you say "Give me three minutes. " What's even more rewarding is the supervisors face when you say a huge change like that will take three minutes. You fire up conText or whatever textEditor you use and replace "100" with "130". Most editors can replace multiple numbers, words etc. etc. with another one. (This will not work if you have all the basejoints at a value of 100 for instance, but since you know that this might happen you coded all the basejoints to 101. Stay ahead of corrections :) ) Then you load the MEL-script into Maya and run it once. Overwrite the file and tell the animators to try it out. They are satisfied and you can go home to your girlfriend while these animators are the ones working overtime with their new rig getting into their own fights when they come home
at 11 pm. :)

Now I'm going to go through one final thing before I let you go. I'm going to add a control for jIndex_top so you can rotate it independently of the curlControl. What this means is that you can use the Index attribute under Curl to curl the indexfinger and then you can tweek the position of the top joint by using this new attribute called indexTop. I'll add a seperator called Additional Curl so you con't lose control.


Since we know how to do this with MEL we don't use the "Set Driven Key" Window anymore. Simply add these lines to your script:

setDrivenKeyframe -dv -10 -v 56 -cd nHandControl.indexTop jIndex_top.rotateZ;
setDrivenKeyframe -dv 0 -v 0 -cd nHandControl.indexTop jIndex_top.rotateZ;
setDrivenKeyframe -dv 10 -v -126 -cd nHandControl.indexTop jIndex_top.rotateZ;

I did this to show you that the jIndex.rotateZ can have multiple inputs. If you select this joint now and look at the attribute, it has turned yellow.

I Actually learned something by writing this tutorial as well. I hope you, the reader, learned something too. I tried to split this tutorial between the very basics of Driven Keys and then to intermediate. If you couldn't keep up with the MEL-part, take a look at this tutorial in a couple of months when you have started learning MEL ( of course, since you know now what tremendous power that lies within MEL )

If something was badly written, if you didn't understand this, if you find some typos or if you feel like giving me any kind of feedback please use the contact form at the top of this site. I appreciate all kinds of feedback.

Oh, and by the way. Here's the finished file if you want to play around with it I didn't set the other joints to have additional curl so if you would like to try it out feel free to wreck the file :) ( Remember to create a backup first of course).

To download use this link

< previous page

1 | 2 | 3
Related Tutorials

Setting up animation controls in Maya

by Martin Andersson
published on 2009-12-09

Keywords: animation, controls, maya,

rating star fullrating star fullrating star fullrating star fullrating star full (1)
Comments 0 Views 26555

Modelling and Rigging a nut and bolt

by Martin Andersson
published on 2007-04-12

Keywords: nut, bolt, modeling, maya,

rating star fullrating star fullrating star fullrating star fullrating star full (1)
Comments 0 Views 94362

mel ShapeEditor

by Martin Andersson
published on 2009-12-09

Keywords: maya, shape, editor,

rating star nonerating star nonerating star nonerating star nonerating star none (0)
Comments 0 Views 39140

Making of 'Retro Space Common'

by Devon Fay
published on 2014-10-03

Keywords: Maya, V-Ray, Photoshop, Retro, Interior, Scene, Space

rating star fullrating star fullrating star fullrating star fullrating star half (14)
Comments 0 Views 40184
Readers Comments (Newest on Top)
no comments!
No comments yet. Be the first to comment!
Add Your Comment..