生徒(98AD0318)によって作られたMELスクリプトを参考までに以下に示す。
このスクリプトはMAYAによって作られたポリゴンデータの座標値と結線情報を別々のファイルに書き出すものである。
// Sample Mel Script
// by Yoshihiro Komori ( 98AD0318 )
// Thu Feb 10 01:48:48 2000
global proc dxf()
{
window -menuBar true -w 400 -h 400 -title "KOMORI DXF WINDOW" dxfWindow;
columnLayout columnLayout;
textFieldGrp
-label "INPUT OBJECT NAME" nameField;
textFieldGrp
-label "INPUT SAVE FILE NAME" directryField;
text -label " ";
button -label "OUT DXF" -w 400 -command "outDxf();";
button -label "CLOSE" -w 400 -command "deleteUI dxfWindow";
setParent ..;
showWindow;
}
global proc outDxf()
{
float $xyz[];
vector $position[];
int $i, $j;
float $eight = 100000000.0;
int $sample;
string $name = `textFieldGrp -query -text dxfWindow|columnLayout|nameField`;
string $directry = `textFieldGrp -query -text dxfWindow|columnLayout|directryField`;
$directry = ($directry);
select $name;
int $pointnum[] = `polyEvaluate -v`;
int $pointfnum[] = `polyEvaluate -f`;
int $pnum = $pointfnum[0];
getFaceVer($name,$pnum,$directry);
$fileId=`fopen ($directry + ".kmr") "w+"`;
fprint ($fileId, $pointnum[0]+"\n" );
for ($i=0;$i<$pointnum[0];$i++)
{
$xyz = `pointPosition -w ( $name + ".vtx[" + $i + "]" )`;
for($zz = 0; $zz < 3; $zz ++ )
{
$sample = int( $xyz[$zz] * $eight );
$xyz[$zz] = float($sample) / $eight ;
}
$position[$i] = << $xyz[0], $xyz[1], $xyz[2] >>;
fprint ($fileId, $position[$i]+"\n" );
}
fflush $fileId;
fclose $fileId;
}
global proc getFaceVer(string $name,int $pnum,string $directry)
{
int $num,$i,$z;
string $separate[];
string $mmm[];
string $tmp;
string $dum;
int $komori;
int $f;
int $e,$s,$y;
string $ystring;
$mmm[1] = "x";
$f = `fopen ($directry + "face.kmr") "w+"`;
fprint ($f, $pnum + "\n");
for($z = 0;$z < $pnum;$z ++)
{
$tmp = `polyListComponentConversion -tv ($name + ".f[" + $z + "]")`;
$num = `tokenize $tmp " " $separate`;
for($i = 0; $i < $num; $i ++)
{
tokenize $separate[$i] ".vtx" $mmm;
tokenize $mmm[1] "[" $mmm;
tokenize $mmm[0] "]" $mmm;
tokenize $mmm[0] ":" $mmm;
$komori = `size $mmm`;
if( $komori == 1 )
{
fprint ($f, $mmm[0]+" " );
}
if( $komori == 2 )
{
$s = int ($mmm[0]);
$e = int ($mmm[1]);
for($y = $s; $y <= $e; $y ++)
{
$ystring = string ($y);
fprint ($f, $ystring+" " );
}
}
}
fprint ($f, "\n" );
}
window -menuBar true -w 40 -h 50 -title "RESULT" resultWindow;
columnLayout columnLayout2;
text -label " ";
text -label " success !!";
button -label " O K " -w 40 -command "deleteUI resultWindow";
setParent ..;
showWindow;
fflush $f;
fclose $f;
}
dxf();