top of page
  • Writer's pictureFernanda

Passing mel scripts as python in Maya | Tech Art Bites

Updated: May 21, 2021

Have you ever tried reverse-engineering a MEL command in Maya only to find the python equivalent doesn't exist? That happens to me sometimes and it makes me so sad y'all. :(

There is a way to make it work, at the cost of making your script slower. So I'd avoid it unless you can't work around it.

We start by importing the mel library at the very top of our script:

import maya.mel as mel

And whenever we want to use a mel command we pass it as a string to mel.eval()

mel.eval('searchReplaceNames "left" "right" "selected";')

Note: if your mel arguments are being passed as strings inbetween " " (like above), you should use ' ' to define the beginning and end of your command string so Maya doesn't get confused.

You can still modify your arguments by using string concatenation. Just make sure the arguments are always passed as strings or make them into strings with the str() method.

mel.eval("rotate -r -rotate" + axis + " -ocp -os -fo " + amount + ";")

Anyways, remember that mel makes the script lower, so avoid it if you can! Specially if you run it in a loop, oh boy......


159 views0 comments

Recent Posts

See All

Tech Art Q&A #1

Sometimes I get emails from students who want to learn more about Tech Art. Many of them are enrolled in a game development college program and are in need of extra advice and resources. If the studen

bottom of page