Forum rules


Please attach an image to your first post so that a thumbnail is generated in the list of topics.



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Simple maya mel expression (Help!!!)
PostPosted: Wed Feb 08, 2017 3:36 pm 
Droid
Offline

Joined: Tue Feb 07, 2017 9:10 pm

Posts: 3
Hi guys,

I'm attempting a simple mel expression for my character rig, but each time i hit Create in the expression editor it says i have a syntax error in the last line :(

Would anyone please be able to look at my simple expression and help me find what's wrong with it?

Thanks!

//check if there is rotation in Z
if(R_FK_Shoulder_CTRL.rotateZ != 0) {
// if there is rotation in Z, check if there is rotation in X
if(R_FK_Shoulder_CTRL.rotateX !=0) {
//if there is rotation in X, then ik handle roll = rotateX / -2
AO_R_BendArm_ikHandle01.Roll == R_FK_Shoulder_CTRL.rotateX /-2}
// if there is no Rotation in X, then Roll = 0
else {AO_R_BendArm_ikHandle01.Roll == 0}
} // if there was no rotation in Z in the first place, check if there is rotation in Y
else { if(R_FK_Shoulder_CTRL.rotateY != 0) {
// if there is Rotation in Y, check if there is Rotation in Z after Y
if(R_FK_Shoulder_CTRL.rotateZ != 0) ;
// if there is Rotation in Z after Y, Roll = rotateZ / -2
AO_R_BendArm_ikHandle01.Roll == R_FK_Shoulder_CTRL.rotateZ /-2;

else {AO_R_BendArm_ikHandle01.Roll == 0} };
// if there
else {AO_R_BendArm_ikHandle01.Roll == 0};
}


Last edited by Sakura on Wed Feb 08, 2017 7:29 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Simple maya mel expression (Help!!!)
PostPosted: Wed Feb 08, 2017 5:33 pm 
Droid
Offline

Joined: Tue Feb 07, 2017 9:10 pm

Posts: 3
ok I've modified my expression a bit after finding this thread:
http://stackoverflow.com/questions/2875 ... ntax-error

so I've changed the double equal signs back to single for non-comparison equations. Here is an updated script screencapped below:

http://www.tiikoni.com/tis/view/?id=2e98e9b



//check if there is rotation in Z
if(R_FK_Shoulder_CTRL.rotateZ != 0) {
// if there is rotation in Z, check if there is rotation in X
if(R_FK_Shoulder_CTRL.rotateX !=0) {
//if there is rotation in X after Z, then ik handle roll = rotateX / -2
AO_R_BendArm_ikHandle01.Roll = R_FK_Shoulder_CTRL.rotateX /-2}
// if there is no Rotation in X after Z, then Roll = 0
else {AO_R_BendArm_ikHandle01.Roll = 0}
} // if there was no rotation in Z in the first place, check if there is rotation in Y
else { if(R_FK_Shoulder_CTRL.rotateY != 0) {
// if there is Rotation in Y, check if there is Rotation in Z after Y
if(R_FK_Shoulder_CTRL.rotateZ != 0) ;
// if there is Rotation in Z after Y, Roll = rotateZ / -2
AO_R_BendArm_ikHandle01.Roll = R_FK_Shoulder_CTRL.rotateZ /-2;
// if there is no Rotation in Z after Y, Roll = 0
else {AO_R_BendArm_ikHandle01.Roll = 0} };
// if there was no Rotation in Y in the first place, Roll = 0
else {AO_R_BendArm_ikHandle01.Roll = 0};
}



Maya says I have a syntax error at Line 19.1 but I don't understand what I've done wrong.


Top
 Profile  
 
 Post subject: Re: Simple maya mel expression (Help!!!)
PostPosted: Wed Feb 08, 2017 8:33 pm 
User avatar
Administrator
Offline

Joined: Wed Feb 13, 2008 9:46 pm

Posts: 3921

Location: New Zealand
Hey Sakura,

I edited the code from your first post. As you mentioned, you need single '=' signs to assign values.

There were a few issues, some extra ';' and missing curly brackets.

You also have 2 'else' statements in a row. You can't do that - you need to use 'else if' if you want multiples. Only the last one can be 'else'.

I've added a comment as text below (which will be 'yellow' if you paste into the Script Editor), which you NEED TO DELETE before running.

I haven't looked at MEL for a while, but hopefully this works...



Code:
//check if there is rotation in Z
if(R_FK_Shoulder_CTRL.rotateZ != 0) {
   // if there is rotation in Z, check if there is rotation in X
   if(R_FK_Shoulder_CTRL.rotateX !=0) {
      //if there is rotation in X, then ik handle roll = rotateX / -2
      AO_R_BendArm_ikHandle01.Roll = R_FK_Shoulder_CTRL.rotateX /-2;
   }
   // if there is no Rotation in X, then Roll = 0
   else {
      AO_R_BendArm_ikHandle01.Roll = 0;
   }
}
// if there was no rotation in Z in the first place, check if there is rotation in Y
else if(R_FK_Shoulder_CTRL.rotateY != 0) {
   // if there is Rotation in Y, check if there is Rotation in Z after Y
   if(R_FK_Shoulder_CTRL.rotateZ != 0) {
      // if there is Rotation in Z after Y, Roll = rotateZ / -2
      AO_R_BendArm_ikHandle01.Roll = R_FK_Shoulder_CTRL.rotateZ /-2;

   }else if(" 'if' WAS MISSING, NEED CONDITION HERE - cannot have 2 'else' statements in a row"){
      AO_R_BendArm_ikHandle01.Roll = 0;
   }
   // if there
   else {
      AO_R_BendArm_ikHandle01.Roll = 0;
   }
}

_________________
Roger Feron
Administrator
NZCGI
Feron Animation
Linked In


Top
 Profile  
 
 Post subject: Re: Simple maya mel expression (Help!!!)
PostPosted: Wed Feb 08, 2017 11:27 pm 
Droid
Offline

Joined: Tue Feb 07, 2017 9:10 pm

Posts: 3
Worzel wrote:
Hey Sakura,

I edited the code from your first post. As you mentioned, you need single '=' signs to assign values.

There were a few issues, some extra ';' and missing curly brackets.

You also have 2 'else' statements in a row. You can't do that - you need to use 'else if' if you want multiples. Only the last one can be 'else'.

I've added a comment as text below (which will be 'yellow' if you paste into the Script Editor), which you NEED TO DELETE before running.

I haven't looked at MEL for a while, but hopefully this works...



Code:
//check if there is rotation in Z
if(R_FK_Shoulder_CTRL.rotateZ != 0) {
   // if there is rotation in Z, check if there is rotation in X
   if(R_FK_Shoulder_CTRL.rotateX !=0) {
      //if there is rotation in X, then ik handle roll = rotateX / -2
      AO_R_BendArm_ikHandle01.Roll = R_FK_Shoulder_CTRL.rotateX /-2;
   }
   // if there is no Rotation in X, then Roll = 0
   else {
      AO_R_BendArm_ikHandle01.Roll = 0;
   }
}
// if there was no rotation in Z in the first place, check if there is rotation in Y
else if(R_FK_Shoulder_CTRL.rotateY != 0) {
   // if there is Rotation in Y, check if there is Rotation in Z after Y
   if(R_FK_Shoulder_CTRL.rotateZ != 0) {
      // if there is Rotation in Z after Y, Roll = rotateZ / -2
      AO_R_BendArm_ikHandle01.Roll = R_FK_Shoulder_CTRL.rotateZ /-2;

   }else if(" 'if' WAS MISSING, NEED CONDITION HERE - cannot have 2 'else' statements in a row"){
      AO_R_BendArm_ikHandle01.Roll = 0;
   }
   // if there
   else {
      AO_R_BendArm_ikHandle01.Roll = 0;
   }
}



Wow YES IT'S WORKING!!!!!!!!!!!!!!!!! Thank you SO MUCH!!!!!!!!! I was stuck on this one for days... Thank you Worzel!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:D


Top
 Profile  
 
 Post subject: Re: Simple maya mel expression (Help!!!)
PostPosted: Thu Feb 09, 2017 1:26 pm 
User avatar
Administrator
Offline

Joined: Wed Feb 13, 2008 9:46 pm

Posts: 3921

Location: New Zealand
No worries! Glad it worked! :thumbsup:

_________________
Roger Feron
Administrator
NZCGI
Feron Animation
Linked In


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

About Us


Contact Us


Advertise on NZCGI

Powered by phpBB® Forum Software © phpBB Group
Logo Design by - Oliver Hilbert Revilo Designs