Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / MEL error not getting resolved
  RSS 2.0 ATOM  

MEL error not getting resolved
Rate this thread
 
64104
 
Permlink of this thread  
avatar
  • Total Posts: 1
  • Joined: 02 February 2012 05:53 AM

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.

[b]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
;[/b]

However This code is showing an error:

“No object matched name .translateX”
or
“No object matched name .tx”..

Please help.



Replies: 0
avatar
  • ldunham1
  • Posted: 06 February 2012 10:34 AM

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.



Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 0