Maya
Maya is a 3D software suite created by Autodesk.
- 2016 online Help
- Creative Crash script and plugin database, maintained by Will McCullough
Custom Marking Menus
(from the Polycount Forum thread Replace context sensitive marking menus posted by "rares")
How to replace the context sensitive marking menus with marking menus of your own, that you can edit in the marking menu editor. The context marking menus that maya comes with (the ones bound to shift and ctrl in your viewport and uv editor) are the only ones you cannot edit via the marking menu editor. These marking menus are stored in the following mel files. We'll tackle only the ones that are bound to Shift, because these are the ones I wanted to change the most:
For the viewport :
- contextPolyToolsEdgeMM.mel
- contextPolyToolsFaceMM.mel
- contextPolyToolsVertexMM.mel
- contextPolyToolsObjectMM.mel
- contextPolyToolsUVMM which was never implemented
The mel file that tells Maya which marking menu to run depending on what's selected :
- contextPolyToolsMM.mel
For the uv editor:
- texturePanel.mel
Maya does not display these marking menus in the marking menu editor for two reasons :
- Maya needs a file to have a "menu_" prefix and for it to be stored in the "markingMenus" folder to recognize it as a marking menu.
- The mel files need to follow a certain "formula" so that the marking menu editor can "understand" them.
At this point you might think that it's possible to just copy the first 4 files I've listed to your markingMenus folder, add the "menu_" prefix to them and then just edit them in the marking menu editor once you open Maya. However, if you do this, you will see them in your marking menu editor, but they will be empty, because they are not "written" like regular marking menus.
So now that we have defined the problem we can get to the solution :
1. Go to your Maya instalation folder and search for these .mel files :
- contextPolyToolsMM.mel
- texturePanel.mel
2. Copy these files to your documents/maya/scripts folder
3. Open contextPolyToolsMM.mel
4. Search for this line of code "global proc int contextPolyToolsMM(string $parent)"
- This is the procedure that decides what marking menu will pop up when you select a component or object and you press shift and right click.
5. Replace the implicit marking menus with your own marking menus.
Say I want to replace the marking menu that pops up when I have a vertex selected with a marking menu that I've created and named "raresVertexTools" .. I scroll down until I find this snippet:
// // Poly vertex is selected. // string $vertexList[] = `filterExpand -expand false -selectionMask 31 $selection`; if (0 != `size($vertexList)`) { [COLOR="Red"][B]contextPolyToolsVertexMM;[/B][/COLOR] // allow user to define a proc with additional menu items if (`exists contextPolyToolsVertexUserMM`) contextPolyToolsVertexUserMM $parent; return 1; } //
And I replace contextPolyToolsVertexMM; with this "source menu_raresVertexTools" so now the code will look like this :
// // Poly vertex is selected. // string $vertexList[] = `filterExpand -expand false -selectionMask 31 $selection`; if (0 != `size($vertexList)`) { [COLOR="Green"][B]source menu_raresVertexTools;[/B][/COLOR] // allow user to define a proc with additional menu items if (`exists contextPolyToolsVertexUserMM`) contextPolyToolsVertexUserMM $parent; return 1; } //
If you wanted to replace the marking menu that pops up when a face is selected you would need scroll further down and find "contextPolyToolsFaceMM" and replace it with "source menu_whateverYourMarkingMenuIsCalled"
6. Open texturePanel.mel
7. Search for "global proc textureWindowCreatePopupContextMenu( string $parent ) "
This is the procedure that creates the context sensistive marking menus in the uv editor
For the marking menus that pop up in the uv editor things are slightly trickier because the marking menu are hardcoded into this procedure. So you have to delete the code that defines these marking menus and in it's place write "source menu_yourMenu"
So now, if you want to replace the marking menu that pops up when you have uvs selected you scroll down untill you find :
////////////////////////////////////////////////////////////// // // UV // ////////////////////////////////////////////////////////////// if (`gmatch $firstSelected[0] "*.map*"`) {
Now what follows is the "definition" of the marking menu that Maya comes with. Mine looks different because it's been written a while back by a friend at work, before we were aware of the trick I'm showing you... essentially this was the old school way of modifying context sensitive marking menus.
menuItem -enableCommandRepeat 1 -radialPosition "S" -annotation "Horizontal rotate" -label "ctRotate" -command "ctOrizontalRotate();" ; menuItem -enableCommandRepeat 1 -radialPosition "SW" -annotation "Rotate UVs to the left by 90 deg" -label "Rotate 90 Left" -command "AMCRotateUVCmd(90)" ; menuItem -enableCommandRepeat 1 -radialPosition "SE" -annotation "Rotate UVs to the right by 90 deg" -label "Rotate 90 Right" -command "AMCRotateUVCmd(-90)" ; menuItem -enableCommandRepeat 1 -radialPosition "E" -annotation "Flip UVs localy on V axis" -label "Flip V" -command "polyForceUV -flipVertical -local;" ; menuItem -enableCommandRepeat 1 -radialPosition "N" -annotation (uiRes("m_texturePanel.kWindowContextUnfoldUVsAnnot")) -label (uiRes("m_texturePanel.kWindowContextUnfoldUVs")) -command "unfold -i 500 -ss 0.001 -gb 0 -gmb 0.4397 -pub 0 -ps 0 -us off" ; menuItem -enableCommandRepeat 1 -radialPosition "N" -optionBox 1 -annotation (uiRes("m_texturePanel.kWindowContextUnfoldUVsOptionsAnnot")) -command "performUnfold 1" ; menuItem -enableCommandRepeat 1 -radialPosition "W" -annotation "Flip UVs localy on U axis" -label "Flip U" -command "polyForceUV -flipHorizontal -local;" ; /* menuItem -command "vrnUVSnapper();" -annotation "Snap UV shells together" //-label "Shell Match Exact" -radialPosition "NE" ;*/ menuItem -command "cpMatchShellCenterSimple();" -annotation "Shell Match" -label "Shell Match" -radialPosition "NW" texSmudgeUVButton ;
You delete the entire "definition" until you reach this code :
// allow user to define a proc with additional menu items if (`exists contextUVToolsUVUserMM`) contextUVToolsUVUserMM $parent; }
The above snippet is harmless, since Autodesk put it there in case someone wanted to write their own context sensitive marking menus (like the ones for the PolyTools), but who wants to deal with that shit when you have a perfectly good marking menu editor.
8. Add your won marking menu that pops up when uvs are selected in the uv editor window : "source menu_myMenu;"
So now the code should look like this :
////////////////////////////////////////////////////////////// // // UV // ////////////////////////////////////////////////////////////// if (`gmatch $firstSelected[0] "*.map*"`) { [B][COLOR="SeaGreen"]source menu_myMenu;[/COLOR][/B] // allow user to define a proc with additional menu items if (`exists contextUVToolsUVUserMM`) contextUVToolsUVUserMM $parent; }
Rinse and repeat for poly vertex and edge.
IMPORTANT: After you save these files, and you play with your new context sensitive marking menus, you might decide that you want to add or remove elements from them. After you make these changes with the marking menu editor you must close Maya and open it again for the changes to take effect.
THE END