Changed mel.mel example file.

This commit is contained in:
Nicholas Breslow 2013-12-10 14:03:23 -05:00
commit a6c6028f7e

View file

@ -1,49 +1,33 @@
proc float edgeCalc(string $edge)
// animated duplicates, instances script
proc animatedDuplication (int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance)
{
int $range_start = $rangeStart;
int $range_end = $rangeEnd;
int $num_of_duplicates = $numOfDuplicates;
int $step_size = ($range_end - $range_start) / $num_of_duplicates;
int $i = 0;
int $temp;
float $distance;
select -r `polyListComponentConversion -tv`;
string $connectedVerts[] = `filterExpand -ex 1 -sm 31`;
vector $PT1 = `pointPosition -w $connectedVerts[0]`;
vector $PT2 = `pointPosition -w $connectedVerts[1]`;
float $distance = mag(($PT1-$PT2));
return $distance;
}
currentTime $range_start; // set to range start
global proc edgeLength()
{
source roundoff.mel;
string $edges[]= `filterExpand -ex 1 -sm 32`;
string $unit = `currentUnit -q -l`;
float $edgeLength[];
int $conversion = 10;
float $totalLength=0; // <= Init your sum variable
//save edgelength to var for later
for($i=0;$i<`size $edges`;$i++)
{
select -r $edges[$i]; // Select only one edge
$edgeLength[$i] = edgeCalc($edges[$i]);
$totalLength += $edgeLength[$i] * $conversion;
}
float $rounded_mm = `roundoff $totalLength 0`;
float $rounded_m = `roundoff (($totalLength)/1000) 2`;
string $edgeno = (size($edgeLength));
string $edgenoprint;
if(size($edgeLength)>1) {
$edgenoprint = " edges";
}
else {
$edgenoprint = " edge";
}
string $selectedObjects[]; // to store selected objects
$selectedObjects = `ls -sl`; // store selected objects
select $selectedObjects;
print ($rounded_mm + " mm / " +$rounded_m+ " m - Total length of " + $edgeno + $edgenoprint +"\n");
select -r $edges; // restore previous selection
}
while ($i <= $num_of_duplicates)
{
$temp = $range_start + ($step_size * $i);
currentTime ($temp);
// seleced the objects to duplicate or instance
select $selectedObjects;
if($duplicateOrInstance == 0)
{
duplicate;
}
else
{
instance;
}
$i++;
}
}