krystof
02-09-2011, 10:11 PM
hello,
In my scene i have 244 meshes randomly placed along the grid. I was looking for a script that could take the "centre" from each one of the meshes and then create a curve that would link them. After some search i found the script that can calculate the "centre" of the meshes but i couldnt apply it to all of them at once. I had to choose one of them at a time and the apply the script. Because of that i began to write a new script that would work automatically for my scene. So far so good. Then i tried to change the "centre" point to a curve point so as to create a curve. But when i run the script every "centre" becomes a one-point curve which i can not manipulate. I would appreciate it very much if someone could help me. Below is the script i used:
for($j=1; $j<245; $j++){
$blob = "test6_blogram_" + $j;
select -r $blob;
string $poly[] = `ls -sl`;
if($poly[0] != "")
{
string $verts[] = `polyInfo -fv $poly[0]`;
string $vert[] = stringToStringArray($verts[0],
"FACE :");
string $obj[] = `ls -sl -objectsOnly`;
int $numVerts = (`size ($vert)`-2);
float $px=0;
float $py=0;
float $pz=0;
for ($i=1; $i< ($numVerts+1); $i++)
{
string $vertID = ($obj[0]+".vtx["+$vert[$i]+"]");
float $pos[] = `xform -q -ws -t $vertID`;
$px += $pos[0];
$py += $pos[1];
$pz += $pos[2];
}
vector $center = <<($px/$numVerts), ($py/$numVerts),
($pz/$numVerts)>>;
print ("center point of "+$poly[0]+ " is: "+ $center);
xform -os -t ($center.x) ($center.y) ($center.z)
locator1;
string $initialCurve = (`curve -p ($px/$numVerts) ($py/$numVerts) ($pz/$numVerts)`) ;
rename $initialCurve ("curve_pt_" + $j);
};
}
thanks in advance:)
In my scene i have 244 meshes randomly placed along the grid. I was looking for a script that could take the "centre" from each one of the meshes and then create a curve that would link them. After some search i found the script that can calculate the "centre" of the meshes but i couldnt apply it to all of them at once. I had to choose one of them at a time and the apply the script. Because of that i began to write a new script that would work automatically for my scene. So far so good. Then i tried to change the "centre" point to a curve point so as to create a curve. But when i run the script every "centre" becomes a one-point curve which i can not manipulate. I would appreciate it very much if someone could help me. Below is the script i used:
for($j=1; $j<245; $j++){
$blob = "test6_blogram_" + $j;
select -r $blob;
string $poly[] = `ls -sl`;
if($poly[0] != "")
{
string $verts[] = `polyInfo -fv $poly[0]`;
string $vert[] = stringToStringArray($verts[0],
"FACE :");
string $obj[] = `ls -sl -objectsOnly`;
int $numVerts = (`size ($vert)`-2);
float $px=0;
float $py=0;
float $pz=0;
for ($i=1; $i< ($numVerts+1); $i++)
{
string $vertID = ($obj[0]+".vtx["+$vert[$i]+"]");
float $pos[] = `xform -q -ws -t $vertID`;
$px += $pos[0];
$py += $pos[1];
$pz += $pos[2];
}
vector $center = <<($px/$numVerts), ($py/$numVerts),
($pz/$numVerts)>>;
print ("center point of "+$poly[0]+ " is: "+ $center);
xform -os -t ($center.x) ($center.y) ($center.z)
locator1;
string $initialCurve = (`curve -p ($px/$numVerts) ($py/$numVerts) ($pz/$numVerts)`) ;
rename $initialCurve ("curve_pt_" + $j);
};
}
thanks in advance:)
