|
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.
|
|
|
|
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
|
|
|