View Full Version : (very) simple mel problem
psilo 06-23-2008, 11:14 AM hi people ,
i m totaly new to scripting , what i want to do is to change some parameters on a lot of objects, so what i tried to do is :
string $selection[]=`ls -sl`
for ($selection in $selections) {
setAttr filmFit 1
}
and it give me : syntax error for " for ($selection in $selections) { "
i think i dont understood well what i have to do to create a loop , if someone can help me ....
thanks.
|
|
digitalandrew
06-23-2008, 11:52 AM
Hi
You have the variables around the wrong way. Should read...
for ($selections in $selection) {
what that line is saying is that you want to perform an action on all the elements in the array... it's a good way to remember the order with a for-in loop :)
cheers
greatPumpkin
06-23-2008, 03:24 PM
You'll also need to refer to the thing you selected inside the loop (the setAttr line would have errored as well)-
string $selection[]=`ls -sl`;
for ($sel in $selection)
{
setAttr ($sel + ".filmFit") 1;
}
psilo
06-26-2008, 06:35 PM
Thanks a lot !
psilo
06-26-2008, 10:11 PM
got another question :
if i want to connect (for example) the scaleX of plenty of objects from a selection to the scaleX of one object, how i can do that? i think i must use the connectAttr function but i dont know how to synthax it.
thanks again,
see you.
misterdi
06-27-2008, 06:20 AM
got another question :
if i want to connect (for example) the scaleX of plenty of objects from a selection to the scaleX of one object, how i can do that? i think i must use the connectAttr function but i dont know how to synthax it.
thanks again,
see you.
connectAttr [-force (file:///C:/Program%20Files/Autodesk/Maya8.5/docs/Maya8.5/en_US/Commands/connectAttr.html#flagforce)] [-lock (file:///C:/Program%20Files/Autodesk/Maya8.5/docs/Maya8.5/en_US/Commands/connectAttr.html#flaglock) boolean] [-nextAvailable (file:///C:/Program%20Files/Autodesk/Maya8.5/docs/Maya8.5/en_US/Commands/connectAttr.html#flagnextAvailable)] [-referenceDest (file:///C:/Program%20Files/Autodesk/Maya8.5/docs/Maya8.5/en_US/Commands/connectAttr.html#flagreferenceDest) string] sourceAttribute destinationAttribute
assuming $source is the source object and $target is the target object, and you intend to force the connection
connectAttr -force ($source + ".scaleX") ($target + ".scaleX")
Of-course in better way, one should check if the attribute already has connections (maybe has been animated) or checking it's lock status, just to make sure that reconnecting the attribute will not break things.
Cheers,
CGTalk Moderation
06-27-2008, 06:20 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.