View Full Version : New and undocumented? - menuItem for shelfButton
Haider of Sweden 08-22-2006, 07:32 AM Hello
I use to use a script that adds menuItems to shelf icons. Before, in maya7 and older, you couldn't add anything to the shelf_abc.mel file and avoid having it overwritten when maya quits.
The only thing that you could leave there was the docTag. Using the docTag as an identifier, you could attach menu-items to single shelf icons.
Now, suddently things got screwed up when I moved all my old preferences from Maya7 to Maya8. I went looking for what was wrong and found that maya did add lots of "-mi" to my shelfButtons. Thats cool - I was so sure it wasnt possible before. That means, I wont need to use external scripts any longer to add popup menus to my shelf buttons/icons.
Question is: Where can I find more info? It seems not to be documented. Or am I not finding it in the online manual?
|
|
goleafsgo
08-22-2006, 06:56 PM
If you are creating a shelfButton you can use "-menuItem <string> <string>" to add a RMB (I think it's RMB) popup menu. The first string you give it is the menu text, and the second is a mel callback procedure (although I could have those backwards...). These menu's will not be overwritten when Maya closes/starts.
Haider of Sweden
08-29-2006, 07:19 AM
Hello, and thank you for your reply.
It is an RMB popup menu, but I cant get any more info about the <string> <string> part. Like, how can I get attributes that are available for regular popup menus. I can for example make the font bold, I can add optionboxes, I can add dividers and maybe more things can be added that I dont know about.
This might be a not-so-very supported features. However, the weird thing is that when I create popup menus by MEL (macaronis zoo-script), Maya somehow recognizes them and adds them as -mi inside the shelf. That messes the whole thing up :sad:
If someone knows about what can be done with the -mi <string> <string>, I would be very happy to know.
Haider of Sweden
11-27-2006, 07:06 AM
I will reply to this thread, to push it up.
Is there anyone who has experience in this issue? I want to turn this build in feature off, sice its still buggy, and go back to my own custom solution.
Priority 2 is to shut off the shelve-save on exit. Is that possible? Only disable the shelve-save?
goleafsgo
11-27-2006, 12:54 PM
I've never looked at macaronis script so I'm not sure what it is that he is doing. Which script is it that you are using? I could take a look at what it does and maybe suggest something...
Haider of Sweden
11-27-2006, 01:14 PM
Hey Tim, thank you for taking your time.
I am using macaronis zooShelveIt.mel script.
What it does is simply looking for a tag (-tag some_name) that is being added to each of the shelf button that I want to add an popupMenu for.
After sourcing the zooShelveIt.mel script, I also source a mel-file that contains all the popupMenus that I created. An example of a popup menu could be:
//////// Smooth menu //
string $buttons[] = `zooShelveItGetShelfButtonAll smooth_tag`;
for( $a in $buttons ) {
string $menu = `popupMenu -p $a -aob 1 buttonPopMenu`;
menuItem -l "0 Smooth" -bld true -c "string $selection[] = `ls -sl`;polySmooth -mth 0 -dv 0 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $selection[0];";
menuItem -l "Optionbox" -ob 1 -c "SmoothPolygonOptions;";
menuItem -l "Global Polygon Smooth Control" -c "source sogc_gpsl;";
}
//////// Smooth menu END //
Now in the shelf-mel file, I need to tag the icon that I want to add the above menu for like this:
shelfButton
-enableCommandRepeat 1
-enable 1
-width 34
-height 34
-manage 1
-visible 1
-preventOverride 0
-annotation "Smooth: Add polygons to the selected polygon objects to smooth them"
-docTag "smooth_tag"
-align "center"
-label "Smooth"
-labelOffset 0
-font "tinyBoldLabelFont"
-image "polySmooth.xpm"
-image1 "polySmooth.xpm"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "polyPerformAction \"polySmooth -mth 0 -dv 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1\" f 0"
-doubleClickCommand "performPolySmooth 1"
-actionIsSubstitute 0
;
Now, what maya8 does is, it does a copy of my popup menu items, and creates a -mi tag into so that the result looks like this (note that the result wasnt correctly copied :sad: )
shelfButton
-enableCommandRepeat 1
-enable 1
-width 34
-height 34
-manage 1
-visible 1
-preventOverride 0
-annotation "Smooth: Add polygons to the selected polygon objects to smooth them"
-docTag "smooth_tag"
-align "center"
-label "Smooth"
-labelOffset 0
-font "tinyBoldLabelFont"
-image "polySmooth.xpm"
-image1 "polySmooth.xpm"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "polyPerformAction \"polySmooth -mth 0 -dv 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1\" f 0"
-doubleClickCommand "performPolySmooth 1"
-actionIsSubstitute 0
-mi "0 Smooth" ( "string $selection[] = `ls -sl`;polySmooth -mth 0 -dv 0 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $selection[0];" )
-mi "Optionbox" ( "SmoothPolygonOptions;" )
-mi "Global Polygon Smooth Control" ( "source sogc_gpsl;" )
-mi "0 Smooth" ( "string $selection[] = `ls -sl`;polySmooth -mth 0 -dv 0 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $selection[0];" )
-mi "Optionbox" ( "SmoothPolygonOptions;" )
-mi "Global Polygon Smooth Control" ( "source sogc_gpsl;" )
;
It creates multiple copies, and doesnt even take all the options and stuff I might have added into my custom made menu.
This method is awesome, being able to create popupMenus to each shelf-icon. While just the shelf itself is a super-cool feature that other programs should take after, this popup thing makes it even cooler, giving you a super-shelve :thumbsup:
So, the solution I would like to see is having it working the way it did back at maya7.
The second best solution would be a tweak that hinders maya from saving the shelve on exit - instead, I need to save them manually OR, adding some kind of onExit function, that asks me everytime if I want to save the shelve or not. A bit boring, but what else to do?
If you need me to come back with anything else, just tell.
Thanx in advance.
goleafsgo
11-28-2006, 04:00 PM
Sorry, I haven't had a ton of time to look into this.
I tried a test and I wasn't able to reproduce the writing out of the menu items twice. I took a quick look at the code and I don't think that there is a way to stop it from writing it out either. I think if you use the script or you use the new Maya way of doing it it still picks up that the menu's are there and tries to write them out.
I'm guessing that what is happening to you is:
1. You have a script that runs to create the menu items.
2. Maya shuts down and sees the menu's and stores it in it's own way.
3. Maya starts up, creates the menu items that it saved.
4. Your script runs again and creates a new set of menu items.
If this is the case then I'd think that everytime you start up Maya again that you'd get a new set of menu's instead of just 2.
I think your best bet is to maybe run your script once to populate all of your custom menus, then save your Shelves, and then not run the script again.
If that solves the double posting of menu's, would there be any other problems with it? You mentioned not saving out other options for the menu's...maybe we could customize the zoo script you have to update other options on the menu's instead of creating them from scratch...
Haider of Sweden
11-29-2006, 09:28 AM
Hi, and thanx for replying.
... I don't think that there is a way to stop it from writing it out either. ...
...
2. Maya shuts down and sees the menu's and stores it in it's own way.
3. Maya starts up, creates the menu items that it saved.
...
I have a feeling, that if this keeps on like that, the "only" solution is to track down mayas own code that checks if there are menus in the icons, and preventing it to run the menu-saving part.
If that solves the double posting of menu's, would there be any other problems with it?
Well, it simply seems that Mayas -mi option isnt as good as all the other available menutItems.
Example of things that you cant put into shelve-mi's are optionboxes and separators.
As for the double posting, its easy fixed - I simply dont use my script and I add the -mi's that I want manually in the shelve.mel file.
But like I said, the standard -mi for shelves seems not very good, unless Autodesk isnt planning to add more features to it.
maybe we could customize the zoo script you have to update other options on the menu's instead of creating them from scratch...
That is also an option, remaking the zoo-script for Maya8 so that it checks if there are menus already.
At the same time, as long as maya copyies the menus created externally by another script, the zoo-script turns not useful anymore, right?
goleafsgo
11-29-2006, 02:15 PM
Ok...so this is what I have so far.
The shelf button control figures out itself what popupMenu's are connected to it, and they create popup menu's in the same way that the zoo script does it, so the shelf button can't tell the difference between the two.
When the shelfButton command goes to create the menu items it does a simple popupMenu followed by a bunch of menuItem calls with just label and command flags set. The command doesn't directly expose all the options that popupMenu and/or menuItem can set.
What it does expose is the name of the popupMenu's that are attached to the shelfButton.
So if you have a simple popupMenu attached to a shelfButton you can do this to get the names:
int $num = `shelfButton -q -numberOfPopupMenus someShelfButton`;
string $popupMenuNames[] = `shelfButton -q -popupMenuArray someShelfButton`;
Then, using the names you get back you can get the menuItem's attached to them like so:
string $menuItemNames[] = `popupMenu -q -itemArray $popupMenuNames[0]`;
And then using the popupMenu's and the menuItem's I think you can set whatever values you want to set.
When I have more time I'll try to do a little bit of scripting/testing to see if this all works and/or if there is an easier way of doing this.
cheers
CGTalk Moderation
11-29-2006, 02:15 PM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.