Maya导出到Ehome工具.Mel
使用方法将如下代码复制进Mel脚本编辑,全选,中间拖拽到工具栏进行使用
if (`window -ex win1`){deleteUI win1;}
window -t "EOP1.1" -w 214 -h 100 win1;
columnLayout -adjustableColumn true;
button -l "UV横竖打直" -c ("uvheng");
button -l "边_1/2选择" -c ("indexselect");
//button -l "边_1/3选择" -c ("index3select");
//button -l "循环并删除" -c ("loopdelte");
//button -l "边_强制1/2选择" -c ("forceselect2");
//button -l "物体_1/2选择" -c ("objectselect");
//button -l "UV竖向打直" -c ("uvshu");
//button -l "表面积" -c ("ployarea");
button -l "统一UV命名" -c ("changeuvset");
button -l "路径复制" -c ("cvcopy");
text -h 10 " " ;
//button -l "所选物体UV自动展" -c ("autouv");
button -l "不展UV导到Ehome" -c ("expehome(0)");
text -h 2 " " ;
button -l "导到Ehome且展UV" -c ("expehome(1)");
text -h 4 " " ;
text -h 18 "请设置导出 FBX2013版本 二进制类型" ;
text -h 6 " " ;
columnLayout -adjustableColumn true;
button -l "冻结清历史" -c ("recover");
rowLayout -nc 3 -adj 3;
button -l "顶部归零" -c ("topmove");
button -l "底部归零" -c ("downmove");
button -l "导出选择" -c ("ExportSelection;");
window -e -t "EOP1.0" -w 214 -h 100 win1;
showWindow win1;
global proc changeuvset()
{
string $sel[]=`ls -sl` ;
$oi=0;
$i=0;
for($oi=0;$oi<size($sel);$oi++)
{
select -r $sel[$oi];
string $alluvset[]=`polyUVSet -q -allUVSets`;
for ($i=0;$i<size($alluvset);$i++)
{
$ii=$i+1;
string $ti="map"+$ii;
if($ti==$alluvset[$i])
{print "有重名";}
else { polyUVSet -rename -uvSet $alluvset[$i] -newUVSet $ti;}
}
}
}
global proc indexselect()
{ polySelectEdgesEveryN "edgeRing" 2;}
global proc loopdelte()
{polySelectEdgesEveryN "edgeLoop" 1;DeleteEdge ;}
global proc index3select()
{polySelectEdgesEveryN "edgeRing" 3;}
global proc ployarea()
{ float $area[]=` polyEvaluate -area` ;print $area " c㎡"; }
global proc forceselect2()
{
string $seledg[]=`ls -sl`;
string $filter[]=`filterExpand -ex true -sm 32`;
select -cl;
for($i=0;$i<size($filter);$i+=2)
{select -tgl $filter[$i];}
}
global proc uvheng()
{
string $filters[]=`filterExpand -ex true -sm 32`;
if (size($filters)>1)
{
for($i=0;$i<size($filters);$i++)
{
$edges =$filters[$i];
select -r $edges;
$uvbc = `polyEvaluate -bc2`;
polySelectEdges edgeUVLoopOrBorder;
$uvbool=`polyEvaluate -bc2`;
float $uf=$uvbool[2]-$uvbool[0];
float $vf=$uvbool[3]-$uvbool[1];
if ($uf>$vf)
{ textureWindowSelectConvert 4; polyEditUV -r off -v $uvbc[2];}
else{textureWindowSelectConvert 4;polyEditUV -r off -u $uvbc[0];}
}
select -cl;
for($i=0;$i<size($filters);$i++)
{ $edges =$filters[$i]; select -add $edges; }
$uvbc = `polyEvaluate -bc2`;polySelectEdges edgeUVLoopOrBorder ; textureWindowSelectConvert 4;
}
else{
$uvbool=`polyEvaluate -bc2`;
float $uf=$uvbool[2]-$uvbool[0];
float $vf=$uvbool[3]-$uvbool[1];
if ($uf>$vf)
{
textureWindowSelectConvert 4;polyEditUV -r off -v $uvbool[2];
}
else
{
textureWindowSelectConvert 4; polyEditUV -r off -u $uvbool[0];
}
}
}
global proc uvshu()
{
string $filters[]=`filterExpand -ex true -sm 32`;
for($i=0;$i<size($filters);$i++)
{
$edges =$filters[$i];
select -r $edges;
$uvbc = `polyEvaluate -bc2`;
polySelectEdges edgeUVLoopOrBorder ;
textureWindowSelectConvert 4;
polyEditUV -r off -u $uvbc[0];
}
select -cl;
for($i=0;$i<size($filters);$i++)
{ $edges =$filters[$i];
select -add $edges;
}
$uvbc = `polyEvaluate -bc2`;
polySelectEdges edgeUVLoopOrBorder ;
textureWindowSelectConvert 4;
}
global proc objectselect()
{
string $sel[]=`ls -sl` ;
int $selnum=0;
int $sizenum=size($sel);
select -cl ;
for($selnum=0;$selnum<$sizenum;$selnum=$selnum+2)
{
select -add $sel[$selnum];
}
}
global proc cvcopy()
{
pathAnimation -fractionMode true -follow true -followAxis x -upAxis y -worldUpType "object" -inverseUp false -inverseFront false -bank false -startTimeU 1 -endTimeU 100;
snapshot -increment 2 -constructionHistory 1 -startTime `playbackOptions -query -min` -endTime `playbackOptions -query -max` -update force;
selectKey -clear ;
selectKey -add -k -t 1 -t 100 motionPath1_uValue ;
keyTangent -itt linear -ott linear;
selectKey -clear ;
selectKey -add -k -t 1 -t 100 motionPath2_uValue ;
keyTangent -itt linear -ott linear;
selectKey -clear ;
selectKey -add -k -t 1 -t 100 motionPath3_uValue ;
keyTangent -itt linear -ott linear;
selectKey -add -k -t 1 -t 100 motionPath4_uValue ;
keyTangent -itt linear -ott linear;
selectKey -clear ;
selectKey -add -k -t 1 -t 100 motionPath5_uValue ;
keyTangent -itt linear -ott linear;
selectKey -clear ;
}
global proc topmove()
{
string $ss[]=`ls -sl`;
float $bbox[]=`exactWorldBoundingBox`;
CenterPivot;
float $ybbox=($bbox[4]-$bbox[1])/2;
move -r 0 $ybbox 0 $ss.scalePivot $ss.rotatePivot ;
move -rpr 0 0 0 ;;
}
global proc downmove()
{
string $ssd[]=`ls -sl`;
float $dbbox[]=`exactWorldBoundingBox`;
CenterPivot;
float $dybbox=-($dbbox[4]-$dbbox[1])/2;
move -r 0 $dybbox 0 $ssd.scalePivot $ssd.rotatePivot ;
move -rpr 0 0 0 ;;
}
global proc recover()
{
DeleteHistory;
FreezeTransformations;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
}
global proc autouv()
{
DeleteHistory;
string $seledg[]=`ls -sl`;
for($key in $seledg)
{
FreezeTransformations;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
polyAutoProjection -lm 0 -pb 0 -ibd 1 -cm 0 -l 0 -sc 1 -o 1 -p 3 -ps 0.2 -ws 0 -s 2 2 2 $key;
}
select -cl ;
}
global proc expehome(int $input)
{
//删除多余的摄像机
string $cam[] = `ls -type camera`;
int $len = size($cam);
int $i;
for($i=0;$i<$len;$i++)
{
string $str=$cam[$i]+".visibility";
if(getAttr($str)==1)
{
select -r $cam[$i];
pickWalk -d up;
Delete -r;
}
}
//删除nurbers
string $nrs[] = `ls -type nurbsSurface`;
select $nrs;
int $len = size($nrs);
int $i;
for($i=0;$i<$len;$i++)
{
select -r $nrs[$i];
pickWalk -d up;
Delete -r;
}
showHidden -all;
int $num=3;
if($input != 1)
{
$num=5;
}
string $mesh[] = `ls -type mesh`; select $mesh;
if ( catch( `parent -w` ) ) {
print "Could not UVGet\n";
}
DeleteHistory;
SelectAll;
string $seledg4[]=`ls -sl`;
$index=1;
for($key in $seledg4)
{
string $indexc=$index;
string $a=$indexc;
$name="Mesh"+$a;
print $name;
rename($key,$name);
$index=$index+1;
}
for($i=0;$i<$num;$i++)
{
DeleteAllHistory;
SelectAll;
int $again=0;
string $seledg2[]=`ls -sl`;
for($key in $seledg2)
{
print $key;
int $bool;
string $sobj;
string $Sel;
int $num;
$sobj=$key;
$len=size($key)-4;
$shape=startString($key,4);
$num=endString($key,$len);
$shape1=$shape+"Shape"+$num;
$shape2=$shape+$num+"Shape";
select -r $key;
string $arr[] = `pickWalk -d down`;
$Selshape= $arr[0];
if($shape1!=$Selshape && $shape2!=$Selshape)
{
Delete -r $key;
}
else
{
if($Selshape==$key)
{
Delete -r $key;
}
}
}
}
DeleteHistory;
select -cl ;
SelectAll;
string $seledg[]=`ls -sl`;
for($key in $seledg)
{
select -r $key ;
if ( catch( `polyUVSet -currentLastUVSet` ) ) {
print "Could not UVGet\n";
} else {
catch( `polyUVSet -delete`);
}
FreezeTransformations;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
}
select -cl ;
if($input == 1 )
{
SelectAll;
string $seledg[]=`ls -sl`;
for($key in $seledg)
{
if ( catch( `polyAutoProjection -lm 0 -pb 0 -ibd 1 -cm 0 -l 0 -sc 1 -o 1 -p 3 -ps 0.2 -ws 0 -s 2 2 2 $key` ) ) {
print "Could not AutoUV\n";
} else {
// continue on as usual...
}
}
select -cl ;
}
DeleteHistory;
SelectAll;
string $seledg4[]=`ls -sl`;
$index=1;
for($key in $seledg4)
{
string $indexc=$index;
string $a=$indexc;
$name="Mesh"+$a;
print $name;
rename($key,$name);
$index=$index+1;
}
select -r persp ;
toggleVisibilityAndKeepSelection `optionVar -query toggleVisibilityAndKeepSelectionBehaviour`;
select -r top ;
toggleVisibilityAndKeepSelection `optionVar -query toggleVisibilityAndKeepSelectionBehaviour`;
select -r front ;
toggleVisibilityAndKeepSelection `optionVar -query toggleVisibilityAndKeepSelectionBehaviour`;
select -r side ;
toggleVisibilityAndKeepSelection `optionVar -query toggleVisibilityAndKeepSelectionBehaviour`;
SelectAll;
string $seledg[]=`ls -sl`;
if(size($seledg)<2) {
$asuv=`polyUVSet -q -allUVSets`;
$maplen=size($asuv);
if($maplen<2) {
$key=$seledg[0]; polyUVSet -create -uvSet "map2"; polyUVSet -currentLastUVSet;
polyAutoProjection -lm 0 -pb 0 -ibd 1 -cm 0 -l 2 -sc 2 -o 1 -p 6 -ps 0.2 -ws 0 $key;
}
select -cl ;
}
else {
for($key in $seledg)
{
select -r $key ;$asuv=`polyUVSet -q -allUVSets`;$maplen=size($asuv);
if($maplen<2){
polyUVSet -create -uvSet "map2"; polyUVSet -currentLastUVSet;
polyAutoProjection -lm 0 -pb 0 -ibd 1 -cm 0 -l 2 -sc 2 -o 1 -p 6 -ps 0.2 -ws 0 $key;
}
select -cl ;
}
}
DeleteHistory;
FBXExport -f "C:\\EHomeData\\su\\sucache";
$exampleFileName = ( "C:\\EHomeData\\su\\sutoehome.txt" );
$fileId=`fopen $exampleFileName "w"`;
string $t=`date`;
fwrite $fileId $t;
fclose $fileId;
}
//lck