Wednesday, April 11, 2012

Mel eval() and an undetermined amount of flags

Every once in awhile I run into a mel command that requires an undetermined amount of flags to be passed for evaluation. Here's a quick example of how to build and pass an array of flags to eval.


string $curvePoints;
string $myPointArray[];
int $tx;
int $ty;
int $tz;

for($i = 0; $i < 10; $i++)
{
    $tx = $i;
    $ty = $i;
    $tz = $i;
    $myPointArray[$i] = ("-p " + $tx + " " + $ty + " "+ $tz);
}

$curvePoints = stringArrayToString($myPointArray, " ");
print $curvePoints;
eval("curve -d 3" + $curvePoints)

No comments:

Post a Comment