UI button command


#1

I am looking for some syntax help in attaching commands that have to do with window pane display. Example: Button/checkbox to toggle joints/geometry/curves/etc…

Heres the first way I tried it :

 frameLayout -w 450 -l "Visibility" -cll true -cl false -bs "etchedOut";
columnLayout;
 
checkBox -l "Curve Visibility" -al left
			 -occ "string $activePanel = `getPanel -underPointer`; 
 
if(`modelEditor -q -nurbsCurve $activePanel `!=0)modelEditor -e -nurbsCurve 0 $activePanel ; 
 
else modelEditor -e -xray 1 $activePanel ;";
 

and I tried adding the if/else statement before UI and calling if variable is 0 or 1 and change to 1 or 0 and that didnt work either…this is possible right?


#2

okay, here`s the code:

{
window;

frameLayout -w 450 -l “Visibility” -cll true -cl false -bs “etchedOut”;
columnLayout;
checkBox -l “Curve Visibility” -al left -cc “string $activePanel = getPanel -wf; int $value = modelEditor -q -nurbsCurves $activePanel;$value = $value==0 ? 1 : 0; modelEditor -e -nurbsCurves $value $activePanel;”;

showWindow;
}

instead of -underPointer use -withFocus ( -wf ) in order to work properly
the $value = $value==0 ? 1 : 0 sintax means that if $value is 0 it will be replaced by 1 and if it`s not 0 it will be replaced by 0.

salut.yashu.


#3

Sorry for the delayed response, thank you for clearing it up would not have guessed to use a different flag. Is there a different syntax and course of action to use with UI commands in general or is this a special case for viewport options?


#4

in general every UI thing (button, checkbox, etc) has the -c flag where you specify what to do when it’s clicked, etc. For instance put -c “myCommand” to execute myCommand procedure when cliked.
in the command line, type help COMMAND, where COMMAND would be “button”, “checkbox”, or any other MEL command to get a list of it’s flags and some quick help.

salut wai.pa.pa.yashu.


#5

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.