Thursday, August 20, 2009

MEL Errors

For your reference and mine, I'm going to use this post to list common MEL Errors that I get, and to what exactly they were referring. Hopefully this will give you some kind of reference on things to look for in your syntax.

Error | Cause:

∞ "Invalid call to gmatch" | String functions such as 'gmatch' and 'match' are picky about declaration types, so you should explicitly declare the the variables as 'string' variables. Here's a code snippet to illustrate:
This will error out:
proc deleteLoc()
{
$sceneList;
$sceneList = `ls -tr`;
if (`gmatch $sceneList[$i] "*_Tloc"`)
delete $sceneList[$i];
}

This will work, because $sceneList is defined as a 'string' variable:
proc deleteLoc()
{
string $sceneList;
$sceneList = `ls -tr`;
if (`gmatch $sceneList[$i] "*_Loc"`)
delete $sceneList[$i];
}

∞ "$object is an undeclared variable." | This error can be caused by several things. So far, my most common mistakes that generate this, have been forgetting a backtick (`) when declaring a variable, or possibly forgetting a ";" at the end of the preceding line to where I'm calling it. This can also come about if you are using gmatch incorrectly (as in the above example), inside backticks, so that they actually return an empty value to the variable. This means that the variable was never set to anything. For example:

proc deleteLoc()
{
$sceneList = `ls -sl`;
$sceneMatch = `gmatch $sceneList`;
print ($sceneMatch);
}

Would probably get that error, since $sceneMatch never actually received a value.

∞ "Invalid use of Maya object...." | This is usually a forgotten "$" in front of a variable you're calling.


-sd

No comments:

Post a Comment