CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-02-2003, 09:31 PM   #1
Luddy
batGuano
animator
NorCal, USA
 
Join Date: Jan 2003
Posts: 192
simple UI question - radioButtons

I'm trying to rename a selected object with an extension. "Lf" or "Rg". I'm confused on how you query the selected button into another procedure.

global proc renameObj()
{
//?radioCollection -query -select $rcn;
string $curSel[] = `ls -sl`;
//string $newName = "object" + $LR;
//rename $curSel[0] $newName;

}

global proc winProc()
{
string $window = `window`;

columnLayout;

button -label "Rename Selected"
-command renameObj;

rowLayout -columnWidth2 60 60 -numberOfColumns 2;
radioCollection;
string $rightName = "Rg";
string $leftName = "Lf";
$leftName = `radioButton -label "Left"`;
$rightName = `radioButton -label "Right"`;
//?radioCollection -query -select $LR;
showWindow $window;
}
winProc;
 
Old 05-03-2003, 04:34 AM   #2
mark_wilkins
Scream.
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 1,339
You could define a global string and throw the name of the radio button collection into it, then use that variable to query it within your button action procedure.

-- Mark
__________________
Mark R. Wilkins
author of MEL Scripting for Maya Animators
 
Old 05-03-2003, 07:33 AM   #3
X-Tender
Who's Your Daddy!?
 
X-Tender's Avatar
Leveldesigner, 2D/3D Artist
 
Join Date: Mar 2003
Posts: 190
Send a message via ICQ to X-Tender Send a message via AIM to X-Tender
use this .

$radiobuttons = `radioCollection`;



then you can later use

$selection_in_the_radiocollelction = `radioCollection -q -sl $radiobuttons' ;


then you get the selected item (the label string)
__________________
| xt_textureStudio | xt_prefabLibrary |xt_normalis | Get it @ Fuchtelworld V.3 |
 
Old 05-03-2003, 07:48 AM   #4
mark_wilkins
Scream.
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 1,339
as I pointed out though, the variable must be global.

global string $radiobuttons;

etc.

-- Mark
__________________
Mark R. Wilkins
author of MEL Scripting for Maya Animators
 
Old 05-03-2003, 07:25 PM   #5
Luddy
batGuano
animator
NorCal, USA
 
Join Date: Jan 2003
Posts: 192
I'm still confused on how to get "Lf" and "Rg" into $sir (the $leftName, $rightName part). $sir prints out NONE, $radiobuttons prints out radioCollection12, radioCollection13.



global proc renameObj()
{
$radiobuttons = `radioCollection`;
$sir = `radioCollection -q -sl $radiobuttons`;
print $sir;
print " ";
print $radiobuttons;
}

global proc winProc()
{
string $window = `window`;
columnLayout;
button -label "Rename Selected"
-command renameObj;

rowLayout -columnWidth2 60 60 -numberOfColumns 2;

global string $radiobuttons;
$radiobuttons = `radioCollection`;

?? string $leftName = "Lf";
?? string $rightName = "Rg";

$leftName = `radioButton -label "Left"`;
$rightName = `radioButton -label "Right"`;

showWindow $window;
}
winProc;
 
Old 05-03-2003, 09:45 PM   #6
mark_wilkins
Scream.
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 1,339
OK, first off you don't want to reassign the value of $radiobuttons a second time in the renameObj proc. Just define it as a global string in each and they'll share the value.

Second, you weren't indicating that either of the radio buttons had to come up selected. To do this, stick a -sl flag on the command where you make the Left radio button.

Finally, the way to give the actual radio button object the name you want (which is what gets returned when you do a radioCollection -q) is to stick the name you want at the end of the radioButton command. Note that the object name is not the same as the label. In this case, I made Lf and Rg the object names.

There's a simpler way to do all of this if you have a small number of radio buttons and don't want to do anything fancy: use the radioButtonGrp command. It will make all the buttons, label them, hook them together in a collection, select one of them by default, and all in one command. That's the way I talk about doing it in my book, but if you're doing certain more complex things or have more than eight or so radio buttons you'll need to make your own collection like you have.

-- Mark


global proc renameObj()
{
global string $radiobuttons;

$sir = `radioCollection -q -sl $radiobuttons`;
print ($sir + " " + $radiobuttons + "\n");
}

global proc winProc()
{

global string $radiobuttons;

string $window = `window`;
columnLayout;
button -label "Rename Selected"
-command renameObj;

rowLayout -columnWidth2 60 60 -numberOfColumns 2;

$radiobuttons = `radioCollection`;

$leftName = `radioButton -label "Left" -sl "Lf"`;
$rightName = `radioButton -label "Right" "Rg"`;

showWindow $window;
}
winProc;
__________________
Mark R. Wilkins
author of MEL Scripting for Maya Animators

Last edited by mark_wilkins : 05-03-2003 at 09:51 PM.
 
Old 01-15-2006, 02:00 AM   #7
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:22 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.