Introduction to Maya - Modeling Fundamentals Vol 2
This course will look in the fundamentals of modeling in Maya with an emphasis on creating good topology. It's aimed at people that have some modeling experience in Maya but are having trouble with complex objects.
# 1 02-11-2003 , 08:50 AM
nspiratn's Avatar
Registered User
Join Date: Dec 2002
Location: CA
Posts: 211

passing variables to a proc

I'm trying to pass the objectname of the radioButtonGrp to the myProc procedure. But I keep getting an error that $rButton is an undeclared variable. What am I doing wrong?

global proc myProc(string $rButton)
{
string $rButton;
int $nameButton;
$nameButton = `radioButtonGrp -q -sl $rButton`;
print $nameButton;
}

global proc TestGUIscript()
{
string $rButton;
string $window = `window -wh 400 500 -title "Radio Test"`;
rowLayout -nc 3;
text " ";
$rButton = `radioButtonGrp -numberOfRadioButtons 2 -label1 "Hierarchical" -label2 "Alphabetical"`;
print $rButton;
radioButtonGrp -edit -onCommand "myProc($rButton)" $rButton;
showWindow $window;
}

Thanks.


~nspiratn
# 2 02-11-2003 , 12:33 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
First of all, I usually give controls names rather than rely on the ones that maya assigns. Makes life a lot easier user added image

Anyway, in your myProc you have defined $rButton twice. Also you're missing some parenthesis and whatnot in your radioButtonGrp -edit line...

This should work:
Code:
global proc myProc(string $rButton)
{
	int $nameButton;
	$nameButton = `radioButtonGrp -q -sl $rButton`;
	print $nameButton;
}

global proc TestGUIscript()
{
	string $rButton;
	string $window = `window -wh 400 500 -title "Radio Test"`;
	rowLayout -nc 3;
	text " ";
	$rButton = `radioButtonGrp -numberOfRadioButtons 2 -label1 "Hierarchical" -label2 "Alphabetical"`;
	radioButtonGrp -edit -onCommand ("myProc(\"" + $rButton + "\")") $rButton;
	showWindow $window;
}


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 3 02-11-2003 , 12:41 PM
nspiratn's Avatar
Registered User
Join Date: Dec 2002
Location: CA
Posts: 211
COOL! Thanks a lot user added image

YAAAAAAAY!


~nspiratn
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