MaxScript vs. MEL Script

Jan 26, 2009 15:34


At work, I make very frequent use of 3ds Max’s native scripting language, Max Script, to create a number of tools for the art team and to facilitate my own work.  Before coming to Blue Fang, I didn’t know any Max Script at all.  Now, it’s part of my daily routine.  On the flip side, I’ve made occasional use of Maya’s native scripting language, MEL, to accomplish a few things in the past.  I openly admit that I haven’t done nearly as much with MEL as I have with Max Script.

Last night, I ran into a situation in Maya where I cut the position coordinates of every object I had selected by a factor of 0.05 (i.e. 1.0 cm becomes 0.05 cm).  Here’s what it would look like if I needed to write this script in Max Script:
for o in selection do o.pos = o.pos * 0.05

Here’s what it takes to do it in MEL:
string $selection[] = `ls -selection`;
int $i;
for ($i = 0; $i < size($selection); $i++) {
    float $translate[] = getAttr($selection[$i]+”.translate”);
    $translate[0] = $translate[0] * 0.05;
    $translate[1] = $translate[1] * 0.05;
    $translate[2] = $translate[2] * 0.05;
    setAttr($selection[$i]+”.translate”,$translate[0],$translate[1],$translate[2]);
}

It’s no wonder Maya started to include Python support! Of course, while I’m very familiar with Python, I’m not at all familiar with the Python-Maya interface, so I stuck with muddling through via MEL. Still, talk about an unintuitive approach.

Mirrored from Blog-at-McC3D.

code, 3ds max, mel, blue fang, python, work, max script, maya

Previous post Next post
Up