Could it be a problem of your script running before Maya is initialised?

If you cmds.evalDeferred(make_the_menu) then that would let Maya do its
dance before your script kicks in.

On Fri, 19 May 2023 at 00:01, Justin Israel <justinisr...@gmail.com> wrote:

>
>
> On Thu, May 18, 2023 at 5:46 AM A <alimes...@gmail.com> wrote:
>
>> Hey Folks,
>>
>> I have pymel, installed via pip on Maya 2024,
>>
>> Pymel itself is working. But im having a really strange issue.
>>
>> My studio menu is built with pymel...
>>
>> I have a maya module..
>> ib.mod - this then loads the plugin
>> pipeline_module.py - very simple script for making a maya module / plugin
>>
>> pipeline_module.py imports a maya file called pipeline_menu.py "My maya
>> top bar menu"
>>
>> this menu just holds all my tools etc.
>>
>> The module wont load via Maya's GUI "Plugin Manager" "just like you would
>> load vray kind of setup.
>> This worked in Maya 2018 right through to 2023.
>> I need to run manually in the python interpreter "import pymel.core as pm"
>> This might sound simple but both the pipeline_module.py and pipeline.py
>> files run import pymel.core as pm right at the top of both scripts.
>>
>> Why am I now needing to run this before the module will load?
>> The error points to menuOBJ
>>
>> Error Messages...
>> '''
>> // Error: file: C:/Program
>> Files/Autodesk/Maya2024/scripts/others/pluginWin.mel line 316:
>> RuntimeError: file C:\Program
>> Files\Autodesk\Maya2024\Python\lib\site-packages\pymel\internal\pmcmds.py
>> line 217: menu: Object 'menuOBJ' not found.
>> // Warning: file: C:/Program
>> Files/Autodesk/Maya2024/scripts/others/pluginWin.mel line 316: Failed to
>> run file: C:/Users/Alistair
>> Messom/IB/maya_pipeline/mod/plug-ins/pipeline_module.py
>> // Error: file: C:/Program
>> Files/Autodesk/Maya2024/scripts/others/pluginWin.mel line 316:
>>  (pipeline_module)
>> '''
>>
>> My pipeline_menu.py script... well the top of it, the only part that
>> calls or refers to menuOBJ is the string in variable menu_obj = 'menuOBJ'
>>
>
> The error you reported indicates that it comes from the call to
>
> pm.menu(menu_obj, e=True)
>
> where for whatever reason it thinks the 'menuOBJ' menu does not exist.
> Seeing as the label and parent keyword arguments are being ignored in your
> first check for existence, could you not just simplify the whole thing with
> an exception handler?
>
> try:
>     found = pm.menu(menu_obj, e=True)
> except RuntimeError:
>     pass
> else:
>     pm.deleteUI(found)
>
>
> That aside, I don't know why the 'exists' check would succeed, but then it
> fails to find the menu object afterwards.
>
> '''
>> """
>> PIPELINE MENU
>> """
>> import maya.cmds as cmds
>> import pymel.core as pm
>> import os
>>
>> company_name = (
>> os.environ['CUSTOM_PIPELINE_NAME'])
>>
>> def make_the_menu():
>>
>> main_window = pm.language.melGlobals[
>> 'gMainWindow']
>> menu_obj = 'menuOBJ'
>> menu_label = company_name
>>
>> if pm.menu(
>> menu_obj,
>> label=menu_label,
>> exists=True,
>> parent=main_window):
>> pm.deleteUI(pm.menu(menu_obj, e=True))
>> '''
>> Please not if I manually run "import pymel.core as pm"
>>
>> Then activate the module with Maya's GUI "plugin Manager" it opens /
>> works fine.
>> Are we looking at a bug here?
>> I just don't get it!!
>>
>> Thanks,
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/1ade785e-46dd-4181-a2de-aab73c5e6527n%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/1ade785e-46dd-4181-a2de-aab73c5e6527n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3p5%3D8okjufHKxLRtMp-ZAdRYyCuj%3D5DMU1c_hqxegATQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3p5%3D8okjufHKxLRtMp-ZAdRYyCuj%3D5DMU1c_hqxegATQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAzq%3D3XjFXMSAeCyuvTKK_fvkJ42DQK6kX2Qgz8-b%3DfgA%40mail.gmail.com.

Reply via email to