This is because since Maya2010 none of the menu's are actually built
on boot, they get initilized/built when you first open the menu so it
doesn't matter if you defer or not. You just need to build the menu
before adding your options to it:

call the buildFileMenu()  first.

They also did this for the timeSlider in 2011 so you have to call the
"updateTimeSliderMenu TimeSliderMenu" if you want to add anything to
the popmenus for it.

The file menu took us ages initially to debug what was going on, we
had all sorts of lpdeffered going on. ;)

Mark


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

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to