is there any way to convert mel commands to python

84 views
Skip to first unread message

Vishal Kadam

unread,
Jun 18, 2020, 3:53:28 AM6/18/20
to Python Programming for Autodesk Maya
is there any way to convert mel commands to python in maya, I'm using ezMel2Python but it converts into pymel something like pymel.core as pm, I dont know much about mel and python scripting just exploring, so basically what I do is I copy the commands which is generated with in maya keep all in sequence and convert them with ezMel2Python sometimes it works and some times it doesn't

or

is there any other script for maya like if I do any action it should generate python rather than mel command.

please let me know if there is anything like this or any solution where I can get python for mel commands

hope you understand what I'm looking for

Kenneth Ibrahim

unread,
Jul 20, 2020, 3:25:51 PM7/20/20
to python_in...@googlegroups.com
The easiest way of doing (I think) what you're asking is to use PyMEL as it has a really convenient interface for this including the ability to pass the expected function parameters. First import PyMEL as follows:

import pymel.core as pm

Then use PyMEL's "mel" object to execute the MEL command as follows:

pm.mel.sphere(r=100)

Maya's MEL commands are already provided in PyMEL but if you're trying to execute a function written by others (a third party or even yourself) just follow the syntax:

pm.mel.your_command(params_if_any)

For more info run: help(pm.mel)

Hope that helps!

--
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/96b4d8b2-4a9a-42aa-81f0-56d7ea603a19o%40googlegroups.com.


--
"God is a metaphor for a mystery that absolutely transcends all human categories of thought. It's as simple as that!" - Joseph Campbell
Reply all
Reply to author
Forward
0 new messages