I want a simple script to turn the visibility of an object on and off. I actually have it working, but I want to get rid of one extra step. Which is the button. However Maya doesn't seem to like the "-command" in the radioButtonGrp. So if someone knows the solution please let me know... ^^
There are comments in the code to help.
Removed myBtn1 from the radio group and the form layout.
Added attribute to run Global procedure when the status to the radio group is changed.
To be more correct, change the code for the "-select 2" to an if statement that checks the actual visibility status of the pcube1 (or selected object). "2" represents the on position which I changed from "1" since this was to run when the cube was on screen.
Yeah, that works, thanks a lot!
So, why do I need a -change command and doesn't -command work? :/
I used the -command with a global procedure somewhere else and it worked just fine...
Anyway, thanks again! ^^
Re: Radio Button Script Without Button by Steve Sayer on Jan 4, 2012 at 4:28:31 pm
The 'radio button group' control simply doesn't understand the '-command' flag.
Different controls have different functions, just like different nodes have different attributes. A polyCube node doesn't have a "radius" attribute but a polySphere node does; if you tried to use MEL to create a cube and use a '-radius' flag you'd get an error.
In the same way, if you try to create a radio button group control and specify a '-command' flag, you'll get an error because that type of control just doesn't know what '-command' means. Rob's solution with the '-changeCommand' flag is what you were looking for. The reasoning behind naming it something different is that you have more options with a set of radio buttons than you do with a single button. A single button can only be clicked, so it only has the '-command' flag. But a set of radio buttons is more complex; you might want different buttons to do different things, you might want different commands for the 'on' and 'off' states for each, etc., so it has the following series of flags:
Check your Technical Documentation for an explanation of what they all do. In general, you should always be referring to the documentation for each MEL command you use; you can't assume that a flag you've used in one command previously will also be useful in a new command.
Re: Radio Button Script Without Button by Jacqueline Johnsen on Jan 5, 2012 at 12:01:01 pm
Ah yes, that does make sense. I just never tought there would be more than one command.
I do use the Autodesk melscript help, but rarely find my solution there unless it's for something simple like -minValue instead of -min. I just don't understand half of it because I'm not a programmer. :/
I get by, by randomly messing arround in the scripts, googling and using the script editor history. ^^
Got this script working with 3 radiobuttons and altering the height of an object now. \o//
Again thanks! ^^