Reposition using For loop
Reposition
Let say If you want to reposition one object to the other, you can use for loop variation. the script runs through for loop for every string that are declared in first line. try this out. make couple of polyCube and place them at different 3D location. select source object first and then target object (that you want to repostion to the first cube) and execute this in script editor.
string $attributeList[] = {"tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz"};
string $sel[] = `ls -sl`;
string $attribute;
for($attribute in $attributeList) {
setAttr ($sel[1] + "." + $attribute) `getAttr ($sel[0] + "." + $attribute)`;
line 1 : storing all shortnames for tranform attribute in string array (eg: tx = tranformX)
line 2 : declaring string array for storing selected object names
line 3: declaring string that will run through for loop in next line. this line is not needed as maya automatically declares $attr as string type when you use for loop as in line 4
line 4: for loop . to process each string in the array list in line 1 you can use a variation of the for loop that is specialized for use with arrays like this
line 5: setting second selected object transform attribute from first selected object.
If you want any particular channel (like only translate Z and rotate Y ) and not all of them then you use channelBox query like this. make sure you selected the channel in main channel box and run these lines.
string $attributeList[] = `channelBox -q -sma "mainChannelBox"`;
string $sel[] = `ls -sl`;
string $attribute;
for($attribute in $attributeList) {
setAttr ($sel[1] + "." + $attribute) `getAttr ($sel[0] + "." + $attribute)`;
}
Let say If you want to reposition one object to the other, you can use for loop variation. the script runs through for loop for every string that are declared in first line. try this out. make couple of polyCube and place them at different 3D location. select source object first and then target object (that you want to repostion to the first cube) and execute this in script editor.
string $attributeList[] = {"tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz"};
string $sel[] = `ls -sl`;
string $attribute;
for($attribute in $attributeList) {
setAttr ($sel[1] + "." + $attribute) `getAttr ($sel[0] + "." + $attribute)`;
line 1 : storing all shortnames for tranform attribute in string array (eg: tx = tranformX)
line 2 : declaring string array for storing selected object names
line 3: declaring string that will run through for loop in next line. this line is not needed as maya automatically declares $attr as string type when you use for loop as in line 4
line 4: for loop . to process each string in the array list in line 1 you can use a variation of the for loop that is specialized for use with arrays like this
line 5: setting second selected object transform attribute from first selected object.
If you want any particular channel (like only translate Z and rotate Y ) and not all of them then you use channelBox query like this. make sure you selected the channel in main channel box and run these lines.
string $attributeList[] = `channelBox -q -sma "mainChannelBox"`;
string $sel[] = `ls -sl`;
string $attribute;
for($attribute in $attributeList) {
setAttr ($sel[1] + "." + $attribute) `getAttr ($sel[0] + "." + $attribute)`;
}
1 comment:
AYTRA BANDICAI | CASINO - JCM Hub
The Wynn Encore Hotel 당진 출장샵 is 서귀포 출장마사지 a luxury resort, 안산 출장샵 casino and spa with 3 outdoor pools and a casino. It offers a full-service spa, 상주 출장샵 oasis 안동 출장샵 style pools, a restaurant/
Post a Comment