FORUMS: list search recent posts

MEL Question - If/Else Command

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Lord Helmet
MEL Question - If/Else Command
on Apr 21, 2007 at 4:31:59 am

Hello there. I'm trying to make a script to toggle between smooth shaded and wireframe. So far, I can take it half way (shaded to wireframe). However, I can't go back using it. I'm sure that I've done something wrong with the If/Else command, but for all I know, it could be something else (in case you haven't guessed by now, I'm very, VERY new to MEL). Here's what I have so far:

string $modelWindow = `getPanel -wf`;
string $camera = `modelPanel -q -camera $modelWindow`;
if (`modelEditor -e -displayAppearance "smoothShaded" modelPanel4`)
{
modelEditor -e -displayAppearance "wireframe" modelPanel4;
}
else
{
modelEditor -e -displayAppearance "smoothShaded" modelPanel4;
}



Return to posts index

Steve Sayer
Re: MEL Question - If/Else Command
on Apr 21, 2007 at 4:11:40 pm

Hi there. Very close!

The problem is that your 'if' line isn't measuring something, it's actually changing something. The command you've got in forward quotes uses the edit flag instead of the query flag. Since this edit will always return a true result, the consequent statement always executes, reverting the panel back to wireframe. The 'else' line never executes.

Try this line instead:

if (`modelEditor -q displayAppearance modelPanel4` == "smoothShaded")

Beware, though: the fact that you refer explicitly to 'modelPanel4' means you will always be affecting the same panel, making the query to find the active panel useless.

-Steve


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]