The first rule of MELscript:

That’s not a single quote! (It’s not an apostrophe either.)

Allow me to clarify:

If you’ve just started playing around with MEL and you can’t seem to get the simplest command to work, the very first thing you should check is if there are what look like single quotes around some part of the command. Like so:

string $list = [];
$list = ‘ls -sl’;

Is this causing MEL to throw syntax errors? If so, you’re probably typing a single quote (on the same key as the double quote,  to the left of the Enter key). One of the many quirks of MEL is that those are actually backquotes (on the same key as the tilde, to the top left of your keyboard). WHY did they decide to do that? Who knows. Autodesk, man.

Copy in and try this instead:

string $list = [];
$list = `ls -sl`;

Depending on what typeface you use, it can be really difficult to tell the difference. This tripped me up for DAYS when I first started learning MEL. Despite how important this is to know, it’s practically hidden in the Maya User’s Guide… seriously, search for ‘backquote’ and you get 4 hits (those hits are rather helpful in explaining just when you should use backquotes though). But if you don’t even know what a backquote IS in the first place? Well, that’s not going to help you much. But hopefully, this post does!

Leave a Reply

Your email address will not be published. Required fields are marked *