Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / How to query a radioCollection?
  RSS 2.0 ATOM  

How to query a radioCollection?
Rate this thread
 
43359
 
Permlink of this thread  
avatar
  • Total Posts: 31
  • Joined: 08 January 2007 12:09 PM

Hi,

Quick question about querying a radio collection.  Bellow is a simple window, you press the button and it should print the result of the radio collection selection.

I’m not sure the correct way to do this.  Any suggestions?

Thanks!

window -height 240 -width 240 -title “ToolWindow” tlToolWindow;
columnLayout ;

rowLayout -columnWidth4 80 50 50 50 -height 25 -numberOfColumns 4 -width 250;
text “Number of Objects:”;
radioCollection tlRadioCollection;
radioButton -label “None”;
radioButton -label “One”;
radioButton -sl -label “Two”;
setParent ..;

columnLayout ;
separator -h 17 -w 250;
button -height 28 -width 250 -label “print result” -c tlPrintResult ;
separator -h 17 -w 250;
setParent ..;

showWindow;

global proc tlPrintResult()
{
if (`radioCollection -q -select tlRadioCollection` == 1) print “none” ;
if (`radioCollection -q -select tlRadioCollection` == 2) print “one” ;
if (`radioCollection -q -select tlRadioCollection` == 3) print “two” ;
}



Replies: 0
avatar
  • THNKR
  • Posted: 18 May 2010 06:40 AM

You just want to get the label, right?

radioButton --`radioCollection -q -select tlRadioCollection`;


Replies: 1
/img/forum/dark/default_avatar.png

yes, getting the label and printing it is what i want to do when the button is pressed. I’m still confused by how to use this, though… Should it be something like:

global proc tlPrintResult()
{

if ( radioButton -q -l `radioCollection -q -select tlRadioCollection` == 1 ) print “none”;

}

or

global proc tlPrintResult()

{

string $result;

$result = radioButton -q -l `radioCollection -q -select tlRadioCollection`;

print $result;

}

Neither work for me, I’m just trying to figure out the correct syntax.  Thanks for your patience!

Tony

Author: tonthebone

Replied: 18 May 2010 08:45 AM  
avatar

ok, I figured out a way to do it.  I used -onCommand with a global String to do it. 

I’m still curious how to -query the radioCollection.

Thanks for the help!

Tony

_________________________________________________________________________________

global string $tlRadioButtonValue = “One” ;

window -width 150;
columnLayout -adjustableColumn true;

radioCollection;
radioButton -label “One” -sl -onCommand ( “tlRadioButtonOne” ) ;
radioButton -label “Two” -onCommand ( “tlRadioButtonTwo” ) ;

button -label “Print Radio Button” -command ( “getFile2Egg” ) ;

showWindow;

global proc tlRadioButtonOne ()
{
print “one selected” ;
global string $tlRadioButtonValue ;
$tlRadioButtonValue = “one” ;
}

global proc tlRadioButtonTwo ()
{
print “two selected” ;
global string $tlRadioButtonValue ;
$tlRadioButtonValue = “two” ;
}

global proc getFile2Egg ( )
{
global string $tlRadioButtonValue ;
print $tlRadioButtonValue ;
}



Replies: 0