[Closed] removing vertices maxscript … originally solved by bobo
I found a maxscript in this forum that was very close to what I need, but I need help to modify it. I want the script to remove vertices that have exactly two edges connected BUT ONLY WHEN those 2 edges are linear!!!
Here is an exerpt of the original thread that was resolved by BOBO:
…to[color=white] remove any vertices that[/color] have exactly two edges connected? Like the corners of an EPoly plane?
[color=yellow]vertSel = (polyop.getVertSelection $) as array
for i = vertSel.count to 1 by -1 do
(
v = vertSel[i]
select $.verts[v]
nVerts = (polyop.getedgesusingvert $ v) as array
if nVerts.count == 2 do
$.EditablePoly.buttonOp #Remove
)
[/color]
Cheers,
Bobo
Any help is GREATLY appreciated!!!
Alan Lilly (intermediate maxscripter)
Should be simple enough. Get the vector of each edge, and take the acos of the dot product of the two vectors to get the angle between the edges. If it’s 180.0 (minus a tolerance if you wish), remove the vert.
verts_1 = polyop.getedgeverts $ edge1
verts_2 = polyop.getedgeverts $ edge2
vector_1 = verts_1[2] - verts_1[1]
vector_2 = verts_2[2] - verts_2[1]
edge_angle = acos (dot vector_1 vector_2)
if edge_angle > (180.0 - tolerance) do ...
The rest I assume you can get from Bobo’s script.
RH