I am able (in python) to create a custom menu item in the "File" menu that calls one of my python functions.
I am able to get everything loaded up properly through userSetup.py as well. (This is in maya2009 btw).
I can also make a hotkey shortcut so that I can call this same function - however...
For the life of me - I can not figure out how to get the hotkey binding to show up next to my new custom menu entry in the file menu!
Can anyone help me with this?
I will include (below) the various python commands that I use to make this happen - however I'm missing something obviously. For example, if I open the Hotkey Editor GUI I can not see my command under the "File" Category - not sure how to make it show up there - nor if it is even necessary. There is a MEL command called runtimeCommand() that allows you to specify a "category" - but python doesn't have that corresponding command in maya.cmds. Clearly assigning hotkeys to menu items in the "Hotkey Editor" makes the hotkey show up next to the menu item - so there is a way to bind these things together - I just can't figure it out.
Here's what I've done so far - in a file called menuStuff.py:
def fileMenuAdditions() :
gMainFileMenu = mel.eval("$tmp=$gMainFileMenu;")
mel.eval("buildFileMenu()")
menuList = cmds.menu(gMainFileMenu, query=True, itemArray=True)
if (not "savePlusPlusFileMenu" in menuList) :
cmds.setParent(gMainFileMenu, menu=True)
cmds.menuItem("savePlusPlusFileMenu",
label="Save ++",
annotation="Increments the file version - then saves the scene",
command="menuStuff.savePlusPlus()",
insertAfter=menuList[6])
cmds.setParent("..", menu=True)
cmds.nameCommand('savePlusPlusNameCmd', ann="Save++", stp='python', c='menuStuff.savePlusPlus()')
cmds.hotkey(k='S', ctl=True, name='savePlusPlusNameCmd')
def savePlusPlus() :
# You know - saves the file and stuff.
....and here's the contents of userSetup.py:
import maya.cmds as cmds
import maya.mel as mel
import sys
import menuStuff
cmds.evalDeferred("menuStuff.fileMenuAdditions()", lowestPriority=True)
That's all for now - I'm not sure what the best forums are to post questions like this - the Autodesk "The Area" forums don't seem super active, so I think it's between this one and CGtalk, unless anyone can suggest another great active maya forum.