PDA

View Full Version : Loop Help


RavenEye
05-23-2007, 11:37 PM
Can someone assist me with this little loop. I'm still having a difficult time creating loops, so I have no idea where to begin with the syntax error it gave me. Basically I make an easy to do but long to do alot easier and faster.

string $sel[] = `ls -sl`;

for ($cur to $sel)
{
setDrivenKeyframe -cd ("$cur" + ".body") eyeBallR|eyeBallR1.visibility;
setDrivenKeyframe -cd ("$cur" + ".body") eyeBallL|eyeBallL1.visibility;

setAttr ("$cur" + ".body") 0;
setAttr "eyeBallL|eyeBallL1.visibility" 0;
setAttr "eyeBallR|eyeBallR1.visibility" 0;

setDrivenKeyframe -cd ("$cur" + ".body") eyeBallR|eyeBallR1.visibility;
setDrivenKeyframe -cd ("$cur" + ".body") eyeBallL|eyeBallL1.visibility;
}

// Error: for ($cur to $sel) //
// Error: Syntax error //
// Error: }; //
// Error: Syntax error //

_stev_
05-24-2007, 12:54 AM
In your SDK and SetAttr commands, you don't need the quotes around your variable $cur.

Stev

Sick Spider
05-24-2007, 04:27 AM
for ($cur to $sel)

Should be :

for ($cur in $sel)

Plus what _stev_ wrote.

RavenEye
05-24-2007, 04:20 PM
Thanks, guys.

I did try the command ($cur in $sel), but it gave me "couldn't find $cur.body". I guess that is why I shouldn't of put the quotes around $cur. Probably thought that was the name of the object. Anywho it worked thanks for the help.

Xsiv
06-04-2007, 10:59 PM
..
setDrivenKeyframe -cd ("$cur" + ".body") eyeBallR|eyeBallR1.visibility;
setDrivenKeyframe -cd ("$cur" + ".body") eyeBallL|eyeBallL1.visibility;
setAttr ("$cur" + ".body") 0;
..
setDrivenKeyframe -cd ("$cur" + ".body") eyeBallR|eyeBallR1.visibility;
setDrivenKeyframe -cd ("$cur" + ".body") eyeBallL|eyeBallL1.visibility;
..

// Error: for ($cur to $sel) //
// Error: Syntax error //
// Error: }; //
// Error: Syntax error //

*********************************

The problem is with your grouping of the variable $cur.

In the 5 above cases you do not need "quotes" around $cur.

($cur + ".body")

Have fun

Chris

CGTalk Moderation
06-04-2007, 10:59 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.