MEL error not getting resolved

MEL error not getting resolved

Anonymous
Not applicable
303 Views
1 Reply
Message 1 of 2

MEL error not getting resolved

Anonymous
Not applicable
This is a code which I have written to enter all the Names of spheres in a layer and store their co-ordinates in a text file.


float $x,$y,$z;
int $i;
string $filePath="D:\sphereCoordinates.txt";
layerEditorSelectObjects jSpheres;
string $jointSpheres[]=`ls -sl`;
$fileId=`fopen $filePath "a"`;
select -d;
for($obj in $jointSpheres)//$i=0; $i<28; $i++)
{
$x=`getAttr $obj.translateX`;
$y=`getAttr $obj.translateY`;
$z=`getAttr $obj.translateZ`;
fprint $fileId("sphere -n"+$obj+" -p " +$x +" "+ $y+" "+ $z+"\n");
}
fclose $fileId;



However This code is showing an error:

"No object matched name .translateX"
or
"No object matched name .tx"..

Please help.
0 Likes
304 Views
1 Reply
Reply (1)
Message 2 of 2

lee.dunham
Collaborator
Collaborator
The main one i see is your not enclosing the object and attr in the getAttr
$x=`getAttr $obj.translateX`;

you need
$x=`getAttr ($obj+".translateX")`;

also when printing, it might be a good idea to add a space after the name flag.
fprint $fileId("sphere -n "+$obj+" -p " +$x +" "+ $y+" "+ $z+"\n");

finally, (dependant on your platform) you might need to either escape, replace or contain with fromNativePath for the backslash in your filePath. Shown here replaced with a forward slash
string $filePath="D:/sphereCoordinates.txt";

I hope that helps.
0 Likes