In the script editor, I keep a tab for mel to Python conversion.
You can convert a whole script or just some code.
The tab has this code:
import pymel.tools.mel2py as mel2py
# Beware escaped chars - \t needs to be \\t
mel2py.mel2py("C:\Documents and Settings\Administrator\My Documents
\maya\myscripts\\tf_animCurve2drivenKey.mel")
mel2py.mel2py("C:/Program Files/Autodesk/Maya2012/scripts/others/
advanceToNextDrivenKey.mel")
pythonCode = mel2py.mel2pyStr( """
connectAttr -force anim.rotate anim_md.input1;
""")
print pythonCode
To convert a whole script, replace the path inside the quotes, ie C:
\Documents...
The converted script will be placed in the same dir.
To convert code, replace the code in the lines between the triple
qoutes and the converted code will be saved to the pythonCode var.
Sometimes you need to cleanup the code, but its VERY USEFUL
nonetheless.
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe