I'm not sure that will work either as the menus are built on 1st request.
IE the 1st time you click on the menu.
try this...
if( `menu -q -ni $gMainFileMenu` == 0 )
{
catch(buildFileMenu());
}
-Dave
On Mon, Oct 1, 2012 at 12:31 PM, Eduardo Grana <[email protected]>wrote:
> Hello PBLN,
>
> I agree with Mike, i think its because the UI is not there.
> Try running that on userSetup.mel and the ui will be there.
> (you can use mel's python statement like
>
> python ( "import maya.cmds as mc;mc.menuItem('openProject',e=1,en=1);" )
>
> )
>
> Cheers!
>
> PS: Please say hello to Varda on my behalf!
>
>
> On Mon, Oct 1, 2012 at 5:14 AM, Mike Malinowski (LIONHEAD) <
> [email protected]> wrote:
>
>> I am not in front of Maya, so I may be wrong on this but its worth a
>> try. If you place that code in the userSetup.py file it will be executed
>> before any of the Maya GUI is built. Instead, look up the executeDeferred
>> command, then pass what you have there as a string argument.
>>
>> executeDeferred makes maya queue the command up and it will be executed
>> only when Maya first becomes idle ( which in your case will be after Maya
>> has fully loaded ).
>>
>> From: PBLN RAO <[email protected]>
>> Reply-To: "[email protected]" <
>> [email protected]>
>> Date: Monday, 1 October 2012 08:43
>> To: "[email protected]" <
>> [email protected]>
>> Subject: [Maya-Python] How to disable OPen,Save & SaveAs in Maya
>>
>> Hi i am trying to disable the Open,Save & SaveAs items from File Menu
>> and icons on Status Line.
>>
>> I am able to disable the file menu items by below code.
>>
>> import maya.cmds as mc
>>
>> mc.menuItem('openProject',e=1,en=0)
>>
>> mc.menuItem('saveItem',e=1,en=0)
>>
>> mc.menuItem('saveAsItem',e=1,en=0)
>>
>>
>> but i want it to run at maya start-up (may be something like
>> UserSetup.py)
>>
>>
>> The problem is the above code is not working after launching maya.
>>
>>
>> it gives errors as below
>>
>>
>> import maya.cmds as mc
>>
>> mc.menuItem('openProject',e=1,en=0)
>>
>> # Error: RuntimeError: menuItem: Object 'openProject' not found. #
>>
>> mc.menuItem('saveItem',e=1,en=0)
>>
>> # Error: RuntimeError: menuItem: Object 'saveItem' not found. #
>>
>> mc.menuItem('saveAsItem',e=1,en=0)
>>
>> # Error: RuntimeError: menuItem: Object 'saveAsItem' not found. #
>>
>>
>> but if i click the file menu once and use the commands, then it will
>> work perfectly.
>>
>> So how can i make this to work at maya launch/startup.
>>
>>
>> There is no chance of editing the maya files form installation path. as
>> it has to be implemented all over my studio.
>>
>> --
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings:
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>> --
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings:
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>
>
>
> --
> Eduardo GraƱa
> www.assembly3d.com.ar
> www.eduardograna.com.ar
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
--
David Moulder
http://www.google.com/profiles/squish3d
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe