RadiobuttonGrp as switch


#1

HI Guys, and girls…

Im stuck on something that shouldnt be to hard i think.
I have 2 sets of 2 radio buttons.
I want for one set of the radiobuttons to act like a switch.
So If of the radiobuttonGrp the first option is seleted ( that should be by defauult) you see object A and B is hidden. And if you select the other button, you hide object A and show B.

At the moment I have this:

string $MainHooksRadio = `radioButtonGrp  -vr -l "Main Hooks  "  -cc "VisableMainHook();" -numberOfRadioButtons 2  -labelArray2 "MAIN HOOK 2500" "SECOND MAIN HOOK 1200" -select 1 MainRadBtnGrp`;
string $AuxHooksRadio = `radioButtonGrp  -vr -l "Aux Hooks  "  -cc "VisableAuxHook();" -numberOfRadioButtons 2  -labelArray2 "Aux 500" "Aux 750" -select 1 AuxRadBtnGrp`;
global proc VisableMainHook(){ 
	 if (`radioButtonGrp -q -select MainRadBtnGrp` == 1)
setAttr SYREF:SecMainhook_prong.visibility 0;
setAttr SYREF:Mainblock.visibility 1;
	 if (`radioButtonGrp -q MainRadBtnGrp` == 2)
  setAttr SYREF:SecMainhook_prong.visibility 1;
  setAttr SYREF:Mainblock.visibility 0;
	   }
 
global proc VisableAuxHook(){ 
	 if (`radioButtonGrp -q -select AuxRadBtnGrp` == 1)
 setAttr SYREF:Aux_block1.visibility 1;
 setAttr SYREF:YudinAux_block.visibility 0;
	 if (`radioButtonGrp -q -select AuxRadBtnGrp` == 2)
 setAttr SYREF:Aux_block1.visibility 0;
 setAttr SYREF:YudinAux_block.visibility 1;
	   }
 

I tried several ways, sometimes i get them to disapear but they wont show up anymore.
Can some one please help me out?

On the first Global proc i get the error:
// Error: line 18: setAttr: Not enough data was provided. The last 0 items will be skipped. //

and on the second i see:
VisableAuxHook();
so it looks like that is working but it isnt.


#2

I see a “-select” missing in a query statement, so instead of:

global proc VisableMainHook(){ 
	 if (`radioButtonGrp -q -select MainRadBtnGrp` == 1)
setAttr SYREF:SecMainhook_prong.visibility 0;
setAttr SYREF:Mainblock.visibility 1;
	 if (`radioButtonGrp -q MainRadBtnGrp` == 2)
  setAttr SYREF:SecMainhook_prong.visibility 1;
  setAttr SYREF:Mainblock.visibility 0;
	   }

try

global proc VisableMainHook(){ 
	 if (`radioButtonGrp -q -select MainRadBtnGrp` == 1)
setAttr SYREF:SecMainhook_prong.visibility 0;
setAttr SYREF:Mainblock.visibility 1;
	 if (`radioButtonGrp -q -select MainRadBtnGrp` == 2)
  setAttr SYREF:SecMainhook_prong.visibility 1;
  setAttr SYREF:Mainblock.visibility 0;
	   }

#3

Im sorry to say that this didnt fix the problem.
it plays the proces but nothing becomes visible or invisible. :frowning:
is there any other way to do this?

  • edit… sometime they do disapear when i switch but dont come back :frowning:

#4

Oke I figured out what was the problem.

I was not working with a window command.

I changed the cod to this: ( its only a part of what i have but it should work if you execute it.

if ( `window -exists MyWindow` ) {
deleteUI MyWindow;
}
window -s 1 -t "controls" -menuBar true MyWindow; 
menu -label "Options";
menuItem -label "Save File" -command "file -f -save"; // MAKE WINDOW WITH SAVE BUTTON
string $tabs = `tabLayout -w 1000 `; //MAKE TABLAYOUT 
string $Form2 = `formLayout`;
 
	string $SelectForm = `formLayout`;
string $MainHooksRadio = `radioButtonGrp  -vr -l "Main Hooks  "  -cc "VisableMainHook();" -numberOfRadioButtons 2  -labelArray2 "MAIN HOOK 2500" "SECOND MAIN HOOK 1200" -select 1 MainRadBtnGrp`;
 
global proc VisableMainHook(){ 
  if (`radioButtonGrp -q -select MainRadBtnGrp` == 1) VisableMainHookPROC();
  if (`radioButtonGrp -q -select MainRadBtnGrp` == 2) VisableMainHookPROC2();
	}
 
global proc VisableMainHookPROC(){
	setAttr SYREF:Mainhook_grp|SYREF:Mainblock.visibility 1;
	setAttr SYREF:Main_cables.visibility 1;
	setAttr SYREF:SecMainBlock.visibility 0;
	setAttr SYREF:Maintugger.visibility 0;
	setAttr SYREF:Mainhook_tuggers1.visibility 0;
	setAttr SYREF:Newaux_cables_Boom.visibility 0;
	 setAttr SYREF:SecMain_cablesBoom.visibility 0;
}
 
global proc VisableMainHookPROC2(){
	setAttr SYREF:Mainhook_grp|SYREF:Mainblock.visibility 0;
	setAttr SYREF:Main_cables.visibility 0;
	setAttr SYREF:SecMainBlock.visibility 1;
	setAttr SYREF:Maintugger.visibility 1;
	setAttr SYREF:Mainhook_tuggers1.visibility 1;
	setAttr SYREF:Newaux_cables_Boom.visibility 1;
	setAttr SYREF:SecMain_cablesBoom.visibility 1;
} 
 showWindow; 
 

Befor this I had a graphEditor connected to it and that is what made the problem.
I started the script with

tearOffPanel “Graph Editor” graphEditor true;
and then i had all the form and frame layouts.

I deleted this line, added the window command and it worked :slight_smile: