Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 10-12-2004, 02:54 AM   #1
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Unhappy 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;
}
Dann is offline   Reply With Quote
Old 10-12-2004, 05:47 PM   #2
Nimmel
Registered User
 
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
http://www.freelance-animation.com
----------------------------------------------
Nimmel is offline   Reply With Quote
Old 10-12-2004, 08:04 PM   #3
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
Dann is offline   Reply With Quote
Old 11-12-2004, 01:39 AM   #4
Nimmel
Registered User
 
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
http://www.freelance-animation.com
----------------------------------------------
Nimmel is offline   Reply With Quote
Old 11-12-2004, 03:18 AM   #5
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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.
Dann is offline   Reply With Quote
Old 14-12-2004, 12:02 AM   #6
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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!!!
Dann is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.