PDA

View Full Version : autoLegSetup halt!


Tripple-I
12-24-2007, 10:23 PM
umm, so I searched and searched and im finally aggravated enough to post and ask for help.
this is probably a stupid question, as im learning mel and this is my first macro.
Im writing an automatic leg setup that has ik/fk switch, no flip knee (cgtk style), reverse foot, and stretchyness. This is where im getting stopped:

//////////////////////////////////// No Flip Knee /////////////////////////////////////////////////////////


//Create Ik handles
select -r ("Ankle.rotatePivot") ;
select -add ("Ball.rotatePivot") ;
ikHandle -n ("BallIk") -sol ikSCsolver -s 0;

select -r ("Ball.rotatePivot") ;
select -add ("Toe.rotatePivot") ;
ikHandle -n ("ToeIk") -sol ikSCsolver -s 0;

select -r ("Hip.rotatePivot") ;
select -add ("Ankle.rotatePivot") ;
ikHandle -n ("LegIk") -sol ikRPsolver -s 0;
setAttr ("LegIk.stickiness") 1;
setAttr ("LegIk.poleVectorX") .1;
setAttr ("LegIk.poleVectorY") 0;
setAttr ("LegIk.poleVectorZ") 0;
setAttr ("LegIk.twist") 90;

//Create plus/minus average node
shadingNode -asUtility plusMinusAverage;

//connect knee attr to +/- input 1D[0]
select -r ("footControl")

connectAttr -force ("footControl.knee") ("plusMinusAverage1.input1D[0]");

//connect offset attr to +/- input 1D[1]
connectAttr -force ("footControl.offset") (" plusMinusAverage1.input1D[1]");

//connect output 1D to IK twist attr
connectAttr -force ("plusMinusAverage1.output1D") ("LegIk.twist")

//change offset to 90, lock and hide
setAttr ("footControl.offset") 90;
setAttr -lock true -keyable false ("footControl.offset");

//parent Constrain IK's to foot control

select -r ("footControl") ;
select -tgl ("LegIk") ;
parentConstraint -mo -weight 1;

select -r ("footControl") ;
select -tgl ("BallIk") ;
parentConstraint -mo -weight 1;

select -r ("footControl") ;
select -tgl ("ToeIk") ;
parentConstraint -mo -weight 1;



Instead of being helpful, maya selects the plusMinusAverage node and spits out
// Error: No object matches name: connectAttr
Maybe that is helpful, i ain't gettin' it.

r4inm4ker
12-25-2007, 01:36 AM
//////////////////////////////////// No Flip Knee /////////////////////////////////////////////////////////


//Create Ik handles
select -r ("Ankle.rotatePivot") ;
select -add ("Ball.rotatePivot") ;
ikHandle -n ("BallIk") -sol ikSCsolver -s 0;

select -r ("Ball.rotatePivot") ;
select -add ("Toe.rotatePivot") ;
ikHandle -n ("ToeIk") -sol ikSCsolver -s 0;

select -r ("Hip.rotatePivot") ;
select -add ("Ankle.rotatePivot") ;
ikHandle -n ("LegIk") -sol ikRPsolver -s 0;
setAttr ("LegIk.stickiness") 1;
setAttr ("LegIk.poleVectorX") .1;
setAttr ("LegIk.poleVectorY") 0;
setAttr ("LegIk.poleVectorZ") 0;
setAttr ("LegIk.twist") 90;

//Create plus/minus average node
shadingNode -asUtility plusMinusAverage;

//connect knee attr to +/- input 1D[0]
select -r ("footControl") ;

connectAttr -force ("footControl.knee") ("plusMinusAverage1.input1D[0]");

//connect offset attr to +/- input 1D[1]
connectAttr -force ("footControl.offset") (" plusMinusAverage1.input1D[1]");

//connect output 1D to IK twist attr
connectAttr -force ("plusMinusAverage1.output1D") ("LegIk.twist") ;

//change offset to 90, lock and hide
setAttr ("footControl.offset") 90;
setAttr -lock true -keyable false ("footControl.offset");

//parent Constrain IK's to foot control

select -r ("footControl") ;
select -tgl ("LegIk") ;
parentConstraint -mo -weight 1;

select -r ("footControl") ;
select -tgl ("BallIk") ;
parentConstraint -mo -weight 1;

select -r ("footControl") ;
select -tgl ("ToeIk") ;
parentConstraint -mo -weight 1;



i think that's simply some syntax errors. from my experience, if maya said "No object matches name: blablabla", it's usually because i forgot to put ';' after a statement or '$' in front of a variable.

NolanSW
12-25-2007, 03:42 AM
I know how much writing an auto rgging script can be frustrating. One of the problems is trying to come up with all the senarios you may run into and try to accomodate it.

Just a few suggestions that may help you in building your script.
Q: How can I figure out which side I'm working on and name my controls accordingly
A: Based off what is selected, determine which world X axis are you on. If you are on the neg side then you are on the characters "Left" and so on for the right. Simple way to test for this and prefix your controls with either "L_"or "R_". This could also affect settings you have (maybe twist values?).

You don't need to have your script select a control to connect it.
So here is something you can do:

string $side = "L_";
string $control = "footControl";
$control = ($side + $control);
//Create this based off of what side and control you are using and pass that
//variable around
string $plusMinus = `shading -asUtility plusMinusAverage ($control + "_PM)`;
connectAttr -f ($control + " .knee") ($plusMinus + ".input1D[0]");

So by passing the variables around it makes it more modular, cleaner and less hard-coded elements that make it hard to expand your code for anything else down the line you may want to add in the mix.

Keep it up and happy holidays :)

-Sean

Gravedigger
12-25-2007, 01:17 PM
maya doesn't really help you with those error messages. when i can't find the problem i often outcomment: /* ... */ some parts where i assume the problem and run the script. if the error disappears i reactivate some of the outcommented parts and again try the script until the error occurs. with this i can find the error quite quickly

CGTalk Moderation
12-25-2007, 01:17 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.