pymel has a good converter that you can use to convert mel to a python
script:

paste this code into a python panel in maya.

a little prompt will come up for you to enter in some MEL.
paste some MEL in there and
press OK.

in the script editor history panel will have the python  you need converted.
it's not perfect, but it's a good place to start learning if you already
know MEL.


#MEL TO PYimport pymel.core as pmimport pymel.tools.mel2py as mel2py
result = pm.promptDialog(

            title='SPIT BACK PYMEL',
            message='Enter string:',
            button=['OK', 'Cancel'],
            defaultButton='OK',
            cancelButton='Cancel',
            dismissString='Cancel')
if result == 'OK':
    text = pm.promptDialog(query=True, text=True)

    # GET THE PYMEL EQUIVALENT
    pmAnswer = mel2py.mel2pyStr(text,  pymelNamespace='pm')

    # GET RID OF THE OLD WAY
    pmCode = pmAnswer.replace("pymel.all","pymel.core")
    print(pmCode)









On Mon, Jun 1, 2015 at 1:21 PM, Justin Israel <[email protected]>
wrote:

> Haha, yes. You get to put anything your heart desires in that string and
> it will come true.
> Actually, you just put valid MEL syntax into that string, and it will
> execute:
>
> some_mel = "ls -sl"
> mm.eval(some_mel)
>
>
> On Tue, Jun 2, 2015 at 3:47 AM Christopher. <[email protected]>
> wrote:
>
>> When you say (some_mel_code_string) do you mean a string of whatever I
>> want, or mel code as a string, or something else ?
>>
>>
>> On Sunday, May 31, 2015 at 6:42:37 PM UTC-4, Justin Israel wrote:
>>
>>> You can use both MEL and Python in your solutions. MEL goes in mel
>>> files, and python goes in py files.
>>>
>>> How to call python code from your mel scripts:
>>>
>>> http://download.autodesk.com/global/docs/maya2014/en_us/Commands/python.html
>>>
>>> How to call mel code from your python scripts:
>>>
>>> import maya.mel as mm
>>> mm.eval(SOME_MEL_CODE_STRING)
>>>
>>> ​
>>>
>>> On Mon, Jun 1, 2015 at 10:28 AM Christopher. <[email protected]>
>>> wrote:
>>>
>>>> That's what I thought.  How can I have a mixed bag of MEL and Python,
>>>> would you need to see one of the other parts of the script ?
>>>>
>>>>
>>>> On Sunday, May 31, 2015 at 3:49:14 PM UTC-4, Justin Israel wrote:
>>>>
>>>>> You are trying to mix python and MEL syntax together? You can't do
>>>>> that, unless it's Mel code that uses the python() function to call python
>>>>> code, and visa versa.
>>>>>
>>>>> # some .py
>>>>> def foo():
>>>>>     # py syntax
>>>>> foo()
>>>>>
>>>>> // some .mel
>>>>> global proc foo() {
>>>>>     // Mel syntax
>>>>> }
>>>>>
>>>>> On Mon, 1 Jun 2015 7:34 AM Christopher. <[email protected]> wrote:
>>>>>
>>>>>> Hi, I have a script that uses the def() syntax, the problem is the
>>>>>> original code is MEL, using the following syntax is not working ?
>>>>>>
>>>>>> def acme()
>>>>>> [MEL code]
>>>>>> acme()
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>  --
>>>>>> 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 [email protected].
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/python_inside_maya/89a8b58e-6287-467f-b3c3-5137356b6a9b%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/89a8b58e-6287-467f-b3c3-5137356b6a9b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>  --
>>>> 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 [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/89d09d96-1048-44cb-9bf1-676f036c9837%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/89d09d96-1048-44cb-9bf1-676f036c9837%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>  --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/742c2f73-77cf-4175-8047-9006ca88285e%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/742c2f73-77cf-4175-8047-9006ca88285e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA04ny%2BfBRY116oRhBYtF-MH4Ts3aab7Se8d_u8RYfkPMg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA04ny%2BfBRY116oRhBYtF-MH4Ts3aab7Se8d_u8RYfkPMg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CABPXW4hM_YMpAyB8DLbZp9TsWMXUY8BKx-pw%2B%2BVAnP6q49URJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to