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;
}