XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : Feedback RadioButtonGrp

01-13-2012, 09:30 AM
Hey guys, I've created this script where I can alter the visibility of a cube through a melscript GUI pop up window.

It works perfectly, BUT I don't have a feedback function.
I want to be able to use the script and have the correct radiobutton checked.
So it needs to check the vis of the cube and then check the correct radiobutton.

if ( `window -exists MyWindow` ) {deleteUI MyWindow;}
-title "new window"
-widthHeight 300 50
-numberOfDivisions 100
-numberOfRadioButtons 2
-label "Cube"
-labelArray2 "Off" "On"
-changeCommand "visibilityCube();"
-attachForm myRadBtnGrp "top" 10
-attachForm myRadBtnGrp "left" -50
showWindow MyWindow;

global proc visibilityCube() {
if (`radioButtonGrp -q -select myRadBtnGrp` == 1)
setAttr pCube1.visibility 0;
if (`radioButtonGrp -q -select myRadBtnGrp` == 2)
setAttr pCube1.visibility 1; }

I think I need to create a checkVisCub procedure.
global proc checkVisibilityCube() {
if (`pCube1.visibility` == 0)
set radioButtonGrp 1;
if (`pCube1.visibility` ==1)
set radioButtonGrp 2;
Another issue is where do I initiate this procedure?

I'm braindead at the moment (deadline yesterday, too little sleep) so any help will be greatly apreciated. :3

01-13-2012, 10:07 AM
After you showWindow(), have you tried:

if cube vis = 1
window -e myWindow
set radioButton 1

^ poorly written, but basically editing your window and setting its contents after its launched. I often use -e flag after showWindow to resize it to its default dimensions (if it has been resized previously).

Hopefully that makes sense... :p

01-13-2012, 10:32 AM
why do you want to use a pair of radioButtons for something that is essentially an "on/off" state, i.e. a checkbox..?

You can create ui controls that are directly connected to an attribute so the connection works both ways. change the ui control - the attribute updates, change the attribute - the Ui updates. You don't have to monitor or update anything manually. e.g:
columnLayout -adj 1;
attrControlGrp -a "pCube1.visibility";

01-13-2012, 11:16 AM
@ NaughtyNathan Ah thanks, that makes sense! And I will use that, however I also need this script to adjust the textures of clothing through choice nodes. So I still need it to work. But I'll defenitly use your script for the vis functions.

@ Koochy I tried but it didn't seem to work, however I might just be missing some essential basic scripting skills... lol
So, I'm first going to try to set the radiobutton a certain value and once that works, I will try to get it to work in combination with my procedure.

setState "myRadBtnGrp" 1; This code is being ignored... :/ It's in the basic script (not the procedure) Maybe because it hasn't been stated yet? Or because it's not meant to do what I want...

Also trying to adjust the radiobutgrp throug the existing procedure.
global proc visibilityCube() {
if `pCube1 visibility` == 1
setState "myRadBtnGrp" 1;
//set myRadBtnGrp radioButton 1;

01-13-2012, 12:01 PM
...I also need this script to adjust the textures of clothing through choice nodes. So I still need it to work. But I'll defenitly use your script for the vis functions.
don't forget you can use that for most standard attributes on any nodes, it's not just confined to checkboxes and visibility! ;)

CGTalk Moderation
01-13-2012, 12:01 PM
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.