PDA

View Full Version : MEL syntax error which is not getting resolved


Skhinv
01-26-2012, 09:10 AM
This is a code for printing the name and co-ordinates of all the spheres in the scene in a file
however its not getting executed and the error is:
"Cannot convert data of type float[] to type float." :banghead: :banghead: :banghead:
Is getAttr returning a float array??
if yes then how can I convert it into float??

Any other logics to implement this will be more than welcome..



float $x,$y,$z;
int $i;
string $filePath="D:\sphereCoordinates.txt";
layerEditorSelectObjects jSpheres;
string $jointSpheres[]=`ls -sl`;
$fileId=`fopen $filePath "w"`;
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;


I need a solution ASAP..
its an emergency..

Skhinv
01-26-2012, 06:35 PM
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;

OK I figured out the problem in the previous code but now this code is showing an error:

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

ldunham1
02-06-2012, 11:49 PM
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.

Skhinv
02-07-2012, 04:38 PM
Thanks a lot sir!!

Skhinv
02-19-2012, 08:14 AM
I am creating a user interface in MEL

Now I want to make a UI in which after pressing the button it should get disabled.
And only one button should be enabled and the next button will get enabled only after the previous button is pressed.


Logic:
I have come up with the logic that I can use a status variable which will increment only after the button is pressed. And the value of the status variable will decide which button will get enabled.

However I am unable to implement the above logic in MEL code..
Can anyone please help??
Any other option to do what I want to do will also be greatly appreciated.
Thanks in advance..

ThE_JacO
02-24-2012, 02:07 AM
Not that this isn't the forum to ask that question, because it's perfectly pertinent, but given it's extremely MEL and Maya centric, maybe you would have a better exposure to people who can and will help in the scripting subforum for maya?

Feel free to cross post in this particular case, or if you wish I can move this thread there for you.

Skhinv
02-24-2012, 08:13 PM
Alright.. :)
Although I figured out the problem myself.. :P
I will change the location of my next MEL doubt..
Can you give me the link of this subforum??

ThE_JacO
02-27-2012, 02:05 AM
Click the Maya forums, then Maya programming subforums.
http://forums.cgsociety.org/forumdisplay.php?f=89

BTW, it's considered common courtesy, when you find the solution yourself to a problem you were being helped with, to post such solution so that the thread remains useful in the future for people that might bump into the same issue.
It's standard netiquette in programming communities.

Skhinv
02-28-2012, 10:32 PM
Alright..
Didn't know that.. :P
Thanks for the link.
well here is the code:

string $skelInit;
string $b1,$b2,$b3,$b4;
if(`window -ex $skelInit`)
deleteUI $skelInit;

$skelInit=`window -title "Skeleton Initialization"
-wh 256 256`;

formLayout;

rowColumnLayout -nr 4;

$b1=`button -label "Place Joint Spheres"
-en 1 -command "placejSpheres();disable $b1;disable -v 0 $b2"`;
$b2=`button -label "Make Joints"
-en 0 -command "makeJoints();disable $b2;disable -v 0 $b3"`;
$b3=`button -label "Parent Joints"
-en 0 -command "parentJoints();disable $b3;disable -v 0 $b4"`;
$b4=`button -label "Add Icons and Constraints"
-en 0 -command "addIcons();disable $b4;"`;

showWindow $skelInit;

CGTalk Moderation
02-28-2012, 10:32 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.