• Fernanda

Passing mel scripts as python in Maya | Tech Art Bites

Updated: Oct 13, 2020

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......


49 views0 comments

Recent Posts

See All

Character Rigging | Yori | Part IX

I'd like to thank my friend and Character Artist, Miki Bishop, for letting me use this character for this series. https://mikibishop.com/ Jiggly Bits! Right Side of the body! Since we already covered

AutoRigger Showcase | Leg Module

Missed the Arm Module? Check it out! Here's the leg portion of the autorigger. Not much to talk about on this one since the arm and leg modules share a lot of methods. That's the great thing about div