[MEL] getAttr error


#1

Hi,

Can any1 explain my why this is errors out?

string $mySel[] = `ls -os -fl`; 
print `getAttr $mySel[0].translateX`

And when I want to use this in a loop it just prints out some weird stuff

string $mySel[] = `ls -os -fl`; 
for ($obj in $mySel) { 
print `getAttr $obj.translateX`; 
print "
------------------------
"; 
}

For example when I have 5 objects selected is prints out 5 times the X transforms of all the objects, not 1 object per loop:

[B]string $mySel[] = ls -os -fl;
for ($obj in $mySel) {
print getAttr $obj.translateX;
print "

";
};
0
0
-5.392024
-0.015456
4.485874


0
0
-5.392024
-0.015456
4.485874


0
0
-5.392024
-0.015456
4.485874


0
0
-5.392024
-0.015456
4.485874


0
0
-5.392024
-0.015456
4.485874

------------------------[/B]


#2

Ok found the issue. Still getting used to MEL syntax and that commands are parsed as strings, so its should be like this:

getAttr ($item + ".translateX");