Thread: syntax?
View Single Post
# 3 05-12-2004 , 07:06 PM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks KB, I got that part working with your help, so now I'm back for more. I'm trying to link my script to an optionMenu, but can't get it right. I'm not very good at this yet, and the docs are prety crappy when it comes to helping with syntax. Thankfully there are people like you out there.

What it does is it builds a menu based on whatever user created attributes are on your object. Down the road, I'm going to try and read the min/max values of those attributes, and place those values in a field. Then there will be an edit button so I can change the min/max values of each attribute. I have a script that does that, so I'm just working on the interface.

What I am currently stuck on is when I run the script and change the menu selection, I can't get anything to happen. I tried the -command function on the menuItem, but it doesn't work when in optionMenu. I cannot figure out the syntax of the -cc function on the optionMenu, and while the docs claim it runs every time you change your selection, it does not.


global proc optMenu()
{
string $currentObj[] = `ls -sl`;

string $currentObjAttr[]= `listAttr -ud ($currentObj[0])`;
string $currentAttr = ($currentObj[0] +"."+ $currentObjAttr[0]);

int $counter = 0;

string $selected = $currentObjAttr[0];
// string $changeSelected = "print("+$selected+")";

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

rowColumnLayout -numberOfRows 3;
optionMenu -label "Attributes" -cc "($selected = $currentObjAttr[$counter])";
while ($currentObjAttr[$counter] != "")
{
menuItem -label $currentObjAttr[$counter];
$counter +=1;
}
showWindow optMenu_w;
}


Thanks again for the help. Attached is a very simple Maya file you can use to test the script in you are so inclined.

Attached Files
File Type: zip optionmenu.zip (5.7 KB, 141 views)