[分享]MEL Script for you guys!!

各Maya用戶可在這裡交流問題和分享制作經驗

版主: h2o, stantang

[分享]MEL Script for you guys!!

文章Joshua » 16日 5月 2003年, 16:30

Program by enygma

This was kind of a learning project for me, but the end results are practical for what I need them for.

Basically, what this script is made to do is allow you to duplicate a single object onto all selected vertices on a poly object. It is pretty cool to play with. Once I finished, I made just some tests (see attatchment). Keep in mind. This script applies an object to all selected vertices of a poly object. This script has not had any error correction code in it, so selecting nubs or subD verts may not work. Only polys are a garauntee.

vectorPlacement_0.1.mel


code:-------------------------------------------------------------------------------


global vector $sVert[]; //Declare vector array that will contain XYZ values of all selected verts

print "Please Select applicable vertices on polygon mesh, then execute 'vertScan'\n";

proc vertScan()
{
float $vValue[]; //Declare a global floating array that contains the XYZ value of all selected verts
string $vNames[]; //Declare a string array that will contain a list of all objects in the scene
int $countMult1 = -3; //Declare counter multipliers
int $countMult2 = -2;
int $countMult3 = -1;
float $vX; //Vertex X Value
float $vY; //Vertex Y Value
float $vZ; //Vertex Z Value

$vNames = `ls -sl -fl`; //Adds all selected object names to array
$vValue = `xform -query -translation -worldSpace $vNames`; //Extracts World XYZ into new array

for ($counter=0; $counter<(size($vValue)/3); $counter++) //Loop to convert $nNalue into vector array
{
global vector $sVert[]; //Declare global vector array inside the procedure
$countMult1 = $countMult1 + 3;
$countMult2 = $countMult2 + 3;
$countMult3 = $countMult3 + 3;
$vX = $vValue[$countMult1];
$vY = $vValue[$countMult2];
$vZ = $vValue[$countMult3];
$sVert[$counter] = <<$vX, $vY, $vZ>>; //Applies everything from $vValue to a global vector array
}

print "Please select a single object for application, then execute 'applyMesh'\n";

}

proc applyMesh()
{
global vector $sVert[]; //Declare global vector array inside procedure
vector $tempVert; //Declare temporary vector
for ($counter=0; $counter<(size($sVert)); $counter++) //Loop duplicates object onto selected verts
{
duplicate -rr;
$tempVert = $sVert[$counter]; //Assigns current vector array value of $sVert to temporary vector
move -ws ($tempVert.x) ($tempVert.y) ($tempVert.z);
}
clear $sVert;
}
Joshua
CGV討論區會員
CGV討論區會員
 
文章: 126
註冊時間: 2日 6月 2002年, 18:48
來自: Hong Kong/Sydney

Share On:

Share on Facebook Facebook Share on Twitter Twitter

文章lamdy » 18日 5月 2003年, 04:46

how's the function of this script?
哈佬!我系青蛙王子
頭像
lamdy
CGV討論區會員
CGV討論區會員
 
文章: 130
註冊時間: 2日 10月 2002年, 14:00


回到 Autodesk Maya

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 11 位訪客

cron