Maya is MEL, love it or hate it. In 2009 to speed up boot up time. Lots of menus are not built in the interface until a user clicks on the menu item. This then runs a mel proc to build the menu's children. This includes the shelves as well.
There is a MEL script called FileMenu.mel in scripts\startup see the function : global proc buildFileMenu() Just evalDeferred that buildFileMenu() function and then add you new menu items. Don't worry about checking if the menu is built. That's handled in the buildFileMenu proc. -Dave 2010/5/6 Jo Jürgens <[email protected]>: > I had the exact same problem when Maya 2009 came out; they changed something > there. To add something to the menus, you have to ensure that it runs after > absolutely everything has initialized. Not even evalDeferred is enough > > I ended up using a SelectionChanged scriptJob to add the menuItems, that > runs the first time the user clicks something in Maya. > > > > On Thu, May 6, 2010 at 12:01 AM, Justin Rosen <[email protected]> wrote: >> >> Has anyone had problems adding things to the main file menu in >> userSetup.py? >> >> I'm adding our own save menu, leaving the rest of the menus intact. I >> keep getting the following error when maya starts >> >> // Error: file: >> /data/app/cent5_x86_64/Maya/2011/maya/scripts/startup/FileMenu.mel line 341: >> menuItem: Object 'FileMenuRecentFileItems' not found. // >> >> My function is defined in userSetup.py >> >> def CISSaveMenu(): >> from MayaUtils.library.maya.python import CISSave >> >> fileMenu = pm.getMelGlobal('string', 'gMainFileMenu') >> try: >> pm.mel.eval("checkMainFileMenu") >> except: >> pm.mel.eval("buildFileMenu") >> >> pm.menu(fileMenu, edit=True, tearOff=False) >> CISDivider = pm.menuItem('CISSaveDivider', divider=True, >> insertAfter='openFileOptions', parent=fileMenu) >> CISSaveMenu = pm.menuItem('CISSaveItem', parent=fileMenu, label='CIS >> Save', insertAfter='CISSaveDivider', command=pm.Callback(CISSave.main, >> gui=True)) >> CISSaveIncMenu = pm.menuItem('CISSaveIncItem', parent=fileMenu, >> label='CIS Save +', insertAfter='CISSaveItem', >> command=pm.Callback(CISSave.main, gui=False)) >> pm.menu(fileMenu, edit=True, tearOff=True) >> >> >> And i called later on >> >> from pymel.mayautils import executeDeferred >> executeDeferred(CISSaveMenu) >> >> Any ideas? >> >> Also, is there anyway to add option boxes to the menu items? I was able >> to do this in previous versions, but doesn't seem to be the case in 2011, it >> always adds the option box to the Exit item. >> >> Thanks! >> Justin >> >> -- >> http://groups.google.com/group/python_inside_maya > > -- > http://groups.google.com/group/python_inside_maya -- David Moulder http://www.google.com/profiles/squish3d -- http://groups.google.com/group/python_inside_maya
