Go to: Synopsis. Return value. Related. MEL examples.

Synopsis

eval string|expression

eval is NOT undoable, NOT queryable, and NOT editable.

The purpose of the eval command is to provide a way for the user to execute a MEL command or procedure which can only be determined at runtime. Any valid MEL statements can be passed as the string argument to eval. For those familiar with C, this provides a functionality akin to function pointers.

This feature is of particular use to plug-in users. Since a plugin command is available only after the execution of the loadPlugin command, references to that plugin can only be resolved at runtime.

If the user wants to use eval to execute only a single simple command with optional arguments, then he/she can use the 2nd form of the syntax. Otherwise, the user should construct a string consisting of the statements and/or commands to be executed.

Return value

AnyThe return value of the statement or command/procedure call.

Related

evalDeferred, evalEcho, scriptJob

MEL examples

string $timeOfDay = "afternoon";
switch($timeOfDay) {
   case "morning":
      $shape = "circle";
      break;
   case "afternoon":
      $shape = "sphere";
      break;
   case "evening":
      $shape = "cone";
      break;
   default:
      $shape = "cylinder";
   }
   float $radius = 1.4;
   eval $shape -r $radius;  // create specified shape with given radius.

// The "eval" command above could also be constructed as a single string:
eval ($shape + " -r  " + $radius);

eval "int $i = 3 + 2;";

loadPlugin mySpecialNurbCmd.dll;
int $arg1 = 1;
int $arg2 = 10;
eval mySpecialNurb $arg1 $arg2;