Complex UV Layout in Maya
Over the last couple of years UV layout in Maya has changed for the better. In this course we're going to be taking a look at some of those changes as we UV map an entire character
# 1 10-12-2004 , 02:54 AM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695

optionMenu confusion

I'm trying to create a script that uses an option menu, but I cannot figure out how to determine which menu item is currently selected by the user. I'm guesing I want to use -q or -pma, but I can't figure out what to do with them or what the syntax would be, not can I find anything in the docs to tell me.

Help!!

Thanks,
-dann


global proc optMenu2()
{

string $selected = "orange";

window -menuBar true -maximizeButton false -title "Option Menu" -iconName "optMenu2_I" -w 200 -h 150 optMenu2a_w;
columnLayout;

rowColumnLayout -numberOfRows 3;
optionMenu -label "Attributes" -q optMenu2a_w -cc "($selected = ???)";

menuItem -label "orange";
menuItem -label "blue";
menuItem -label "yellow";

showWindow optMenu2a_w;
}

# 2 10-12-2004 , 05:47 PM
Registered User
Join Date: Aug 2004
Posts: 24
You are right about the -q flag, simply use it with -v or -sl to get the result, however, you will need to know the name of the optionMenu to be able to do this. To get around this, name it yourself.

optionMenu -label "Attributes" TestMenu;

The above one forces the name to be TestMenu, so to get it's value use,

optionMenu -q -v TestMenu;

or you can get the value as a string by using the -sl flag.

optionMenu -q -sl TestMenu;



I hope this helps,

Richard


----------------------------------------------
Richard Cheek
https://www.freelance-animation.com
----------------------------------------------
# 3 10-12-2004 , 08:04 PM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks for the help, but I still don't get it. I tried this:

optionMenu -label "Attributes" -q -sl optionMenuName -cc $printSelected;

but I got errors saying that both -sl and -cc were invalid flags. Maybe I don't need the -cc, but that still doesn't explain why it claims those flags are invalid.

I also tried :
optionMenu -q -sl optionMenuName; , but I get the error
"Object not found: optionMenuName"

So in what way am I misunderstanding you?

-dann

# 4 11-12-2004 , 01:39 AM
Registered User
Join Date: Aug 2004
Posts: 24
When you set up the option menu, you don't need to -q flag because you are creating it, not querying it. Latter when you want to query it in another part of your code you use the -q flag.

For example;

global proc optMenu2()
{

string $selected = "orange";

window -menuBar true -maximizeButton false -title "Option Menu" -iconName "optMenu2_I" -w 200 -h 150 optMenu2a_w;
columnLayout;

rowColumnLayout -numberOfRows 3;
optionMenu -label "Attributes" optMenu2_Menu;

menuItem -label "orange";
menuItem -label "blue";
menuItem -label "yellow";

showWindow optMenu2a_w;
}


All I've changed here is the optionMenu line. I took out the -q and the -cc flags and named it optMenu2_Menu.
If you copy and past the above code into maya and then run it (type optMenu2), you will get your window. From here you can query the menu from the script editor by typing;

optionMenu -q -v optMenu2_Menu;

This should allow you to select a menu item and then use the script edit to query it.

If you want to set somthing up when the menu item is changed, this is when you use the -cc flag.

For example copy and paste in the code below to the script editor and then select a new item from the menu. The -cc flag runs the new proc PrintMenu() whenever the menu item changes. This new proc simply querys the menu and prints the results to the scipt editor (so have it open when you change somthing).



// Start Copy Here////////////////////////////////////////
///////////////////////////////////////////////////////////////

global proc PrintMenu()
{
string $MenuValue = `optionMenu -q -v optMenu2_Menu`;

print ("\n\nThe menu item is : " + $MenuValue );
}

global proc optMenu2()
{

if (`window -exists optMenu2a_w`)
deleteUI optMenu2a_w;

string $selected = "orange";

window -menuBar true -maximizeButton false -title "Option Menu" -iconName "optMenu2_I" -w 200 -h 150 optMenu2a_w;
columnLayout;

rowColumnLayout -numberOfRows 3;
optionMenu -label "Attributes" -cc "PrintMenu" optMenu2_Menu;

menuItem -label "orange";
menuItem -label "blue";
menuItem -label "yellow";

showWindow optMenu2a_w;
}

optMenu2;

// EndCopy Here//////////////////////////////////////////
///////////////////////////////////////////////////////////////


I hope this helps

Richard


----------------------------------------------
Richard Cheek
https://www.freelance-animation.com
----------------------------------------------
# 5 11-12-2004 , 03:18 AM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks Richard,

This will be very helpful. I won't be able to look at it until Monday, but I look forward to dissecting it then.

# 6 14-12-2004 , 12:02 AM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
That was just what I needed to get me on the right path. Now all I need to do is plug it in with the rest of my script, get a few other UI things working, and I'm there. All downhill from here.

Thanks again!!!

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads