QUOTE(lxdengar @ 09/12/07, 10:00 AM) [snapback]273187[/snapback]
Excuse me, does anyone know a way to update the shelf icon? This would be great for toggle commands.
thanks!
shelf icons (buttons) are regular MEL/ELF controls and as such can be queried and edited in a number of ways. However, to edit a control you need to know it's name and Maya assigns shelf button names dynamically on creation so there's no way to predict what it will be called. You would have to embed some identifying sting into the shelf button in a place where you knew it would be preserved (inside the edit command would be the most obvious place)
you would then have to write a procedure that the shelf button would call that searched every shelf button for the correct identifying string, thus finding out the control name when it had found the identifier.
here's a psuedo-code example:
your shelf button command would be:
CODE
// grid_icon_toggle_ident:ON:gridOn.bmp
// grid_icon_toggle_ident:OFF:gridOff.bmp
myShelfIconSwitcher "grid -toggle" grid -q -toggle
"grid_icon_toggle_ident"
you would then write a script that went something like this:
CODE
global proc myShelfIconSwitcher(string $cmd,int $on, string $ident)
{
get a list of every shelf
loop through each shelf
get a list of each button on the shelf
loop through each button
query the button command
is the first line in button command == ("//"+$ident+"*")?
if so, execute the $cmd with the $on value
set the shelf icon to the icon listed on ident line $on
}
of course this is a gross simplification, you'd have to do a lot of matching and tokenizing and such, and I've probably got the on/off icons the wrong way round but hopefully you'll get the idea...
However, I don't know if this would really be as useful and helpful as you imagine as it'd be practically impossible to keep track of other events in Maya that could change the status of your toggle and besides, Maya has more than one viewport, and you can toggle the grid (for example) off in one viewport and not in the others... I personally think this whole idea is a bit of a red-herring but hey, you did ask and it perked my interested curiosity.. ![]()
:nathaN