Hi, I don't come on here much but I'm pretty stuck on something. During a project I am doing lately I am finding that I am using the Show > Isolate Select > View Selected command alot. Now I want it as a shelf icon, looking in the hotkep editor the command to turn it on is this :
So now I have 2 buttons, 1 for switching it on and 1 for switching it off, now........ is there a way I can merge the 2 scripts to make 1 toggle button instead of 2 buttons (on/off)?
Hi PREM, thanks for your input, I tried the script, and it works if you have a single view up, but if you have 2 or more viewports up it seems to always affect the top view and not the selected port.
I did do a search for what I was looking for, unfortunately I only did a search for view selected but it gave over 1000 results and my eyes went blurred at around 300 or so, lol. It didn't even occur to me to do a search for enableIsolateSelect, it gave me 5 results.
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
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..
They have changed maya so that this can be done easier. You can give the shelfbutton a exlicit name at creation nowadays (as maya saves the name).
CODE setParent MayaWindow|mayaMainWindowForm|formLayout2|formLayout14|formLayout15|formLayout49|ShelfLayout|Curves; shelfButton -i "commandButton.xpm" -c "updateButton(\"myTestButton\")" myTestButton; // better chek it does not exist when you create it!
off course f you wished to be very savy and vary very vain you could make a scriptjob to watch panel change and update the button then too. And the keyboard shortcut and the menuitem.