PDA

View Full Version : selecting continuous poly edges


tymznd
07-15-2007, 03:46 AM
Need some advice for automating the selection of straight edges. Straight being defined as an edge that purely runs in only 1 (X,Y or Z) direction.

Start with a basic polyPlane 10 x10 - quad
when a displacement is applied, alot of edges are added, many of them diagonal.
I want to keep the edges that run in a single X Y or Z direction.

I thought that I could compare the two verticies of the edge:
so... only 1 of the vals would be different.

ie - this would be selected (kept)
vtx[0] 0 1 1
vtx[1] 0 2 1

this would NOT:
vtx[0] 0 1 1
vtx[1] 0 2 2

is there an easier way to go about this?

_stev_
07-15-2007, 06:28 AM
This should work:


{
// Get the selected object
string $obj[] = `ls -sl`;
// Get the number of edges in object
int $numEdges[] = `polyEvaluate -e $obj[0]`;
// Define array which will hold the index of each orthographic edge
int $orthoEdges[];
// Loop through all edges
for ($i=0; $i<$numEdges[0]; $i++) {
// Query postion of the edge end points
float $vPos[] = `xform -q -t ($obj[0] + ".e[" + $i + "]")`;
// Subtract the resulting positions
$vPos[6] = $vPos[3] - $vPos[0];
$vPos[7] = $vPos[4] - $vPos[1];
$vPos[8] = $vPos[5] - $vPos[2];

// Compare the cross product of the difference
// of the points to each X, Y, and Z axis
// If the result is <<0,0,0>>, then the edge is aligned to the axis
if ((cross(<<$vPos[6],$vPos[7],$vPos[8]>>, <<1,0,0>>)) == <<0,0,0>>)
$orthoEdges[size($orthoEdges)] = $i;
else if ((cross(<<$vPos[6],$vPos[7],$vPos[8]>>, <<0,1,0>>)) == <<0,0,0>>)
$orthoEdges[size($orthoEdges)] = $i;
else if ((cross(<<$vPos[6],$vPos[7],$vPos[8]>>, <<0,0,1>>)) == <<0,0,0>>)
$orthoEdges[size($orthoEdges)] = $i;
}
// This array now has your edges
print $orthoEdges;
}

This will only find edges that are perfectly aligned to the X, Y, or Z axis. You could add a tolerance value in the If statement to make it more flexible.

Stev

tymznd
07-15-2007, 07:04 PM
Much thanks... I will give this a shot.

goleafsgo
07-16-2007, 12:29 PM
You could also try "Select Contiguous Edges". The menu item for it has moved recently I think but it should be in the Polygons menuSet under "Select -> Select Contiguous Edges". And if you can't find it just run "SelectContiguousEdgesOptions;" to get the option box.

CGTalk Moderation
07-16-2007, 12:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.