Normal Display in toggle mel script

Normal Display in toggle mel script

Anonymous
Not applicable
1,838 Views
3 Replies
Message 1 of 4

Normal Display in toggle mel script

Anonymous
Not applicable

Hello !

I'm a newbie in scripting 😄

 

 

For displaying the normal i'm using this :

 

// Normal type
polyOptions -displayNormal true -global;
polyOptions -f;     // on facets
// normal size
polyOptions -sn 0.3;
// Increase normal size
// polyOptions -r -sn 1.5;

 

and to switch off this :

 

polyOptions -displayNormal false -global;

 

-------------------------------------------------------------------------

---------------------------------------------------------------------------

 

It's doing the job 😄

But when i try to regroup it in a simple script to use with a hotkey for example

 

global proc togglenormal()
{
int $tmp[] = polyOptions -displayNormal -global;

if ($tmp[0]) polyOptions {polyOptions -displayNormal false -global;}
else {// Normal type
polyOptions -displayNormal true -global;
polyOptions -f; // on facets
// normal size
polyOptions -sn 0.3;}
}

 

-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

 

I'm having  this :

 

// Error:     int $tmp[] = polyOptions -displayNormal -global; //
// Error: Line 3.30: Invalid use of Maya object "polyOptions". //
// Error:     int $tmp[] = polyOptions -displayNormal -global; //
// Error: Line 3.45: Invalid use of Maya object "displayNormal". //
// Error:     if ($tmp[0]) polyOptions {polyOptions -displayNormal false -global;} //
// Error: Line 5.43: Invalid use of Maya object "polyOptions". //
// Error:     if ($tmp[0]) polyOptions {polyOptions -displayNormal false -global;} //
// Error: Line 5.62: Invalid use of Maya object "displayNormal". //

 

------------------------------------------------------------------------------------

------------------------------------------------------------------------------------

 

 

It's certainly nothing but it's my first "script"

 

Thanks

 

 

 

 

 

 

 

 

0 Likes
Accepted solutions (2)
1,839 Views
3 Replies
Replies (3)
Message 2 of 4

Roland.Reyer
Autodesk
Autodesk
Accepted solution

Hi,

 

in MEL if you want to assign the return values of a command you need to enclose the command in single quotes:

 

   int $tmp[] = 'polyOptions -q -displayNormal ....';

 

But you could also use the toggle commands:

   ToggleFaceNormalDisplay;

   ToggleVertexNormalDisplay;

   ToggleTangentDisplay;

 

You can find these command by:

- turn on "Echo all Commands" in the script editor (then choose the desired function from the menu)

  OR

- put the desired function on the shelf (hold SHIFT+CTRL and click the menu) then analyse the shelf button

 

 

 

0 Likes
Message 3 of 4

mspeer
Consultant
Consultant
Accepted solution

Hi!

@Roland.Reyer

 

To correct this, you need backquotes:

 

$var = `mel_command`;

 

Message 4 of 4

Anonymous
Not applicable

Thanks a lot !

 

it was a detail, but an important one !

 

 I've found the mel reference guide on autodesk web site and other sites, but have you good books reference for mel scripting ?

 

 

Thanks

 

0 Likes