Thanks for all the responses.
Jo, I would consider this a last resort, on SelectionChanged? Does the
scriptJob delete itself after the fact? I would think runOnce would be
better. Although, I haven't actually used many scriptJobs, at least in the
last 2 years, so I'm not sure what their limitations are, if any.
David, "Maya is MEL", I love mel, but she's like your highschool girlfriend,
you're good friends when you see eachother, but you've moved on.
Are you calling the buildFileMenu in a userSetup.py? In my example above I
removed the try/except block and the error went away.
fileMenu = pm.getMelGlobal('string', 'gMainFileMenu')
pm.mel.eval("buildFileMenu")
pm.menu(fileMenu, edit=True, tearOff=False)
CISDivider = pm.menuItem('CISSaveDivider', divider=True,
insertAfter='openFileOptions', parent=fileMenu)
...
I also tried adding an evalDeferred with buildFileMenu before calling my
function. Which actually makes more sense. But, Maya crashes!
*def CISSaveMenu():
from MayaUtils.library.maya.python import CISSave
fileMenu = pm.getMelGlobal('string', 'gMainFileMenu')
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)
**
**pm.mel.evalDeferred("buildFileMenu")
executeDeferred(CISSaveMenu)
*I get the following output when setting export
MAYA_DEBUG_ENABLE_CRASH_REPORTING=1 in the shell.*
*
*ASSERT failure in QList<T>::operator[]: "index out of range", file
/buildforge/Maya_2011_Linux64_Build/source/Maya/platform/linuxamd64/Components/ExternalLibraries/Qt/4.5.3/include/QtCore/qlist.h,
line 403
maya encountered a fatal error
Signal: 6 (Unknown Signal)
Stack trace:
/lib64/libc.so.6 [0x376d4301b0]
gsignal
abort
qt_message_output(QtMsgType, char const*)
qFatal(char const*, ...)
TiceMenuItemCmd::makeObj()
TiceBaseCmd::doCreate()
TiceBaseCmd::doCommand(TargList&)
TpythonInterpreter::dispatchMayaCommand(TmetaCommand&, _object*, _object*)
PyEval_EvalFrameEx
PyEval_EvalCodeEx
/data/app/cent5_x86_64/Maya/2011/maya/lib/libpython2.6.so.1.0
[0x2ab31613f51c]
PyObject_Call
PyEval_EvalFrameEx
PyEval_EvalCodeEx
/data/app/cent5_x86_64/Maya/2011/maya/lib/libpython2.6.so.1.0
[0x2ab31613f51c]
PyObject_Call
PyEval_EvalFrameEx
PyEval_EvalCodeEx
PyEval_EvalFrameEx
PyEval_EvalCodeEx
/data/app/cent5_x86_64/Maya/2011/maya/lib/libpython2.6.so.1.0
[0x2ab31613f41d]
PyObject_Call
TpythonIdleAction::doIdleAction(Tevent const&)
TidleAction::preDoIdleAction(Tevent const&)
TcallBackTidleAction::doIt(Tevent const&)
TeventHandler::doIdles()
QObject::event(QEvent*)
QidleTimer::event(QEvent*)
QApplicationPrivate::notify_helper(QObject*, QEvent*)
Fatal Error. Attempting to save in /usr/tmp/rosenj.20100506.0904.ma
QWidget::setWindowModified: The window title does not contain a '[*]'
placeholder*
Should I do this in a userSetup.mel? Are there any differences worth
mentioning between the two, other then the obvious?
This seems to work for now...
Has anyone figured out how to add an option box to a menu item within the
File Menu? I can't seem to use python or mel...
*fileMenu = pm.getMelGlobal('string', 'gMainFileMenu')*
*pm.menuItem('CISSaveItemOp', parent=fileMenu, label="CIS Save Options",
optionBox=True, insertAfter='CISSaveItem')*
*global string $gMainFileMenu;*
*menuItem -l "CIS Save Options" -ia "CISSaveItem" -p $gMainFileMenu -ob true
**CISSaveItemOp'**;*
Thanks for all the help!
Justin
On Thu, May 6, 2010 at 6:24 AM, Martin Mayer
<[email protected]>wrote:
> Hi i solved it by generating lines form python and appending them to
> ''userSetup.mel', that way you let Maya take care of all loading priorities
> stuff.
> Once imported you can do what you want inside your modules.
>
> example:
> python("import interface.mayaDialogs as md"); // Source or 'import' the
> interface.mayadialogs.py as md
> python("myIntegration=md.mainMenuBar()"); // Intantiate the md.mainMenuBar
> class inside the module
>
> -M
>
>
> On Thu, May 6, 2010 at 6:11 AM, David Moulder <[email protected]>wrote:
>
>> 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
>>
>
> --
> http://groups.google.com/group/python_inside_maya
>
--
http://groups.google.com/group/python_inside_maya