View Full Version : Hi, noobie MEL question... Connecting Attributes
agredbeard 09-21-2009, 06:05 PM I'm trying to connect the Y rotation of multiple selected objects to the Y rotation of another controller type object.
I know that you can connect things with connectAttr - i.e connectAttr pCube1.ry pCube2.ry;
But how can I connect the .ry attributes of multiple selected objects to pCube1.ry?
Any help would be greatly appreciated!
Thanks!
:bowdown:
|
|
benio33
09-21-2009, 10:20 PM
You cannot connect multiple objects to .ry value. It accepts only one datatype. Probably you ment connecting one controller value to multiple .ry values, and therefore I'd recommend using connectAttr put in a simple "for" loop.
Cheers.
agredbeard
09-21-2009, 11:30 PM
thanks benio33!
I did try the "for" loop option. I'm not very experienced in MEL so I'm having trouble with this last desired option.
I'd like for the last selected object to be the one which all the other .rotateY attributes are connected to. So far I have:
string $mySelection [] = ` ls -sl `;
for ( $myNode in $mySelection) {
connectAttr tile181.ry ($myNode + ".ry");
}
So, I'd like to replace tile181.ry with a String which would be the last selected object's .ry attribute. How would I write that?
Thanks!
jaydru
09-22-2009, 12:56 AM
But how can I connect the .ry attributes of multiple selected objects to pCube1.ry?
are you trying to connenect the sum of more than 1 attribute to the destination pCube1.ry,
eg. (randomNodeA.ry + randomNodeB.ry) -> pCube1.ry
if so you could try using a plusMinusAverage node so it would be like...
$plusMinus1 = `createNode plusMinusAverage`;
connectAttr -f nodeA.rotate ($plusMinus1 + ".input3D[0]");
connectAttr -f nodeB.rotate ($plusMinus1 + ".input3D[1]");
connectAttr -f ($plusMinus1 + ".output3D") nodeC.rotate;
if that is what your tring to do?
*edit
just actualy read your last post and that isnt what you want.
$sel = `ls -sl`;
for ($each in $sel)
{
if ($each == $sel[(size($sel) - 1)])
break;
connectAttr -f ($sel[(size($sel) - 1)] + ".ry") ($each + ".ry");
}
that should do it though
Irakli
09-22-2009, 01:09 AM
If you try to connect last selected objects ry to other slected objects the you should write something like this
string $selList[]=`ls -sl`; //list slected object
int $numObj =size($losList); // get selected objects number
int $lastInArray = ($numObj-1); // get last object from list
//loop
int $i ;
for($i=0;$i<$lastInArray;$i++)
{
connectAttr ($losList[$lasInArray]+".ry") ($losList[$i]+".ry") ;
}
Irakli
09-22-2009, 01:18 AM
jaydru wrote more correctly the code :)
vvkonline
09-22-2009, 01:21 AM
all selected objects will be connected to last selected.
string $mySelection [] = `ls -sl`;
int $selectionSize = size($mySelection);
for ($i=0;$i<($selectionSize-1);$i++)
{
connectAttr ($mySelection[$selectionSize] + ".ry") ($mySelection [$i] + ".ry");
}
agredbeard
09-22-2009, 03:02 AM
Thank you all for your replies!!! :buttrock:
JayDru - your suggestion worked and is achieving the desired effect.
Thanks again!
CGTalk Moderation
09-22-2009, 03:02 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.