Not sure if this is applicable in this case, but PyMEL has this great MEL
access mechanism that essentially turns any MEL command into a Python
function complete with arguments:

pm.mel.melCommandName(arg1, arg2, argN)

Here's the doc:
https://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/PyMel/generated/classes/pymel.core.language/pymel.core.language.Mel.html

On Fri, Aug 26, 2022 at 11:27 PM DGFA DAG's GRAPHIC & FOTO ART <
gerome....@gmail.com> wrote:

> In Python it works with Mel commands when I do this
> pm.menuItem(label=‘my menu’, command="mel.eval(‘SetProject’)")
>
>
> DGFA DAG's GRAPHIC & FOTO ART schrieb am Samstag, 27. August 2022 um
> 08:15:14 UTC+2:
>
>> When I do this I get an error "Error line 1.35 Syntax error"
>> When I run his line as standalone python("import mat"; mat.run()"
>> this is working but I need a command for the menuItem that runs Mel
>> commands or python command/script.
>>
>> In Maya documentation there are examples for menu but no one have the
>> flag -c included.
>>
>> vince touache schrieb am Samstag, 27. August 2022 um 01:34:10 UTC+2:
>>
>>> I don't have a maya available to test it currently, but did you try to
>>> run your command via the "python
>>> <https://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/Commands/python.html>"
>>> keyword in MEL?
>>> Calling, in MEL:
>>>
>>> *python "import mat;mat.do_something()" *
>>>
>>> should be understood correctly by your MEL call, I assume
>>>
>>>
>>> Le ven. 26 août 2022, à 18 h 58, DGFA DAG's GRAPHIC & FOTO ART <
>>> gerom...@gmail.com> a écrit :
>>>
>>>> Hi,
>>>>
>>>> I struggle with a custom menu. I will to have my own menu with all the
>>>> stuff I have in several shelfs. But when I codethe menu in Mel I don’t know
>>>> how to set the command attribute for executing a Mel  command.
>>>> For example:
>>>> Mel
>>>> menuItem -p $mainWindow -l "Set Project" -c "SetProject"
>>>> menuItem -p $mainWindow -l "Create Material" -c "source mat.py"
>>>>
>>>> The first line works fine the second throws an error "file mat.py not
>>>> found"
>>>>
>>>> How can I solve this?
>>>>
>>>> Thanks,
>>>> Dag
>>>>
>>>> --
>>>> 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_m...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/fe306d38-7042-4206-8656-b105c298d1a8n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/fe306d38-7042-4206-8656-b105c298d1a8n%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/de96d854-40d0-48e2-b077-d91609f0cc38n%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/de96d854-40d0-48e2-b077-d91609f0cc38n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
"God is a metaphor for a mystery that absolutely transcends all human
categories of thought. It's as simple as that!" - Joseph Campbell

-- 
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/CAP_aC5avGYkS0B4DUvy9T_fma0MvYmKFWEN7fkTK3q-D7Hn-yQ%40mail.gmail.com.

Reply via email to