MELにおいて条件・値によってコマンドを実行するかどうかを決めるには、C言語と同じように if, switchなどを使用する。
if(条件式) { MELコマンド; . . }
if(条件式) { MELコマンド; . . } else { MELコマンド; . . }
if(条件式1) { MELコマンド; . . } else if(条件式2) { MELコマンド; . . } . . . else { MELコマンド; . . }
== != < > <= >= && || ( )
switch(変数) { case 値1 : MELコマンド; . . break; case 値2 : MELコマンド; . . break; . . . default : MELコマンド; . . break; }
半径$radが5.0以下の場合は円上に球を、半径が5.0以上の場合はキューブを$num個並べるMELスクリプト。
global proc circleObjects1(float $rad, int $num) { int $i; float $r = 0.0; float $add = 360.0 / $num; for($i = 0; $i < $num; $i ++) { if($rad <= 5.0) { sphere; } else { nurbsCube; } move $rad 0 0; rotate -ws -p 0 0 0 0 $r 0; $r += $add; } }
global proc circleObjects1(float $rad, int $num)
int $i;
float $r = 0.0;
float $add = 360.0 / $num;
for($i = 0; $i < $num; $i ++)
if($rad <= 5.0) { sphere; } else { nurbsCube; }
move $rad 0 0;
rotate -ws -p 0 0 0 0 $r 0;
$r += $add;
circleObjects3(int 作るプリミティブの種類, float プリミティブを並べる円の半径, float プリミティブの個数)