Monday, January 23, 2012

Mel To Add Spread and Curl Attributes For Fingers

Here is a MEL script I wrote that may come in useful
to help with foot/finger fk/ik rigging.


//make 3 joints on the scene named "joint1", "joint2", "joint3"
//make one nurbs curve control on scene named "ctrl1"

source naAutoAttr.mel

source naGeneral.mel

//type in script editor
naMakeAttr(
"scaleX",
{"joint1","joint2","joint3"},
{"Hi","There"},
{"ctrl1","ctrl1"}
);

naConnectAttr(
"scaleX",
{"joint1","joint2","joint3"},
{"Hi","There"},
{"ctrl1","ctrl1"},
{"Hi","NA","NA"},
{ 2.0,-2.0,1.0,
1.0,1.0,1.0,
1.0,1.0,1.0 }
);

what we have typed are
//what thing we should key -- the scaleX
//all the possible things we want to be able to translate/rotate/scale -- the joints we created.
//names to use for attributes -- here we have two attributes one named Hi, the other There.
//names to use for animator controls -- here we have one control that we will use for both attributes Hi and There.
//which attribute should handle which joint -- here were saying joint2 and joint3 we dont want to move so they have no attribute, but joint1 we would like its scaleX to change with attribute Hi
//what values should thing we should key have: max,min,default for each joint -- here
The 2.0,-2.0,1.0 says that when set driven key (sdk) is at max the scaleX for joint1 should be at 2 times its original size.
When sdk is at min it scaleX should be at -2 times its original size, and when sdk is at default its scaleX should be 1.
For joint2 and joint3 that have no attributes we will leave their scales at 1.

//move attribute Hi and see the scaleX of joint1 changing.


Thanks
Nathaniel