Mel to Python

53 views
Skip to first unread message

Ravi Chandran

unread,
May 9, 2018, 1:57:50 PM5/9/18
to python_in...@googlegroups.com
anyone help me this small mel script to python please 


dgdirty -a

Angelo Sta. Catalina

unread,
May 9, 2018, 2:05:01 PM5/9/18
to python_in...@googlegroups.com
import maya.cmds as cmds
cmds.dgdirty(a=True)

On Wed, May 9, 2018, 12:57 PM Ravi Chandran <rav6ch...@gmail.com> wrote:
anyone help me this small mel script to python please 


dgdirty -a

--
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/CAMgn%3DSZBerZTKHPj6iWxgL2hap3ibDUA14mrpX1YLQULj6ao6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

vincent zaraek

unread,
May 9, 2018, 4:47:39 PM5/9/18
to Python Programming for Autodesk Maya
pymel has a package to convert from Mel to Pyhon, it works for commands and all its flags, and even has a method to convert complete Mel files.
So on your example:
import pymel.tools.mel2py as mel2py
print mel2py.mel2pyStr('dgdirty -a;')
#result: dgdirty(a=1)

the only thing that you need to add the cmds import and the namespace to the command (i.e. from maya import cmds and "cmds." at the beginning)
here you can find more info
Reply all
Reply to author
Forward
0 new messages