1
$\begingroup$

I am working on a road net mesh that only contains edges, no faces. They all share a common plane (I'm basically working in 2D). There is a ton of redundant edges that form ALMOST perfectly straight paths between crossings and could be dissolved but doing it manually with take me ages. On the other hand, there are some road turns that I want to keep.

I'd like to know if Blender has any command that will select my vertices by angle or select similar angle to the one I selected, so I could later dissolve them. Say, my selected vertex connects two edges that are almost parallel, and I want to dissolve all vertices that are like that. I want to be able to set a threshold, so I can keep vertices that connect edges with deviation from parallel larger than 2 degrees, for example.

Here goes a screenshot where I manually selected what I want to be done automatically. The whole mesh is much larger, that's why I'm asking.

enter image description here

If there's no such an option, natively or with an addon, please tell me if it would be difficult to write a script for such an action. Any help greatly appreciated.

$\endgroup$

2 Answers 2

4
$\begingroup$

X > Limited Dissolve does almost exactly what you're asking for, allowing you to set a threshold by angle. It works for frameworks without faces:

enter image description here

(Limited dissolve with increasing thresholds.)

I don't think there's a way to select vertices by edge-angle, though.

You can select edges by face-angle, but that wouldn't suit this case.

$\endgroup$
3
  • $\begingroup$ Limited dissolve works fine and it might even substitute your script in my case. But thank you for it anyway! Do you share somewhere all of your scripts? $\endgroup$
    – michalpe
    Commented Jan 20, 2021 at 18:32
  • $\begingroup$ @michalpe I think this might have been for batFINGER? The reason I put the select-by-angle remark in, though, is that you could tweak his script to select all verts on angles in a range, which would be very useful, and Limited Dissolve can't do. $\endgroup$
    – Robin Betts
    Commented Jan 20, 2021 at 18:44
  • $\begingroup$ Sure, sorry, I haven't noticed that this answer was not from batFINGER. But it's useful too! $\endgroup$
    – michalpe
    Commented Jan 20, 2021 at 19:01
7
$\begingroup$

Select inline verts.

Quick edit mode bmesh script. Run in vert select mode. Selects all vertices connected to 2 edges that have an angle of within 2 degrees of 180 degrees. Think of it like a clock, and the angle between the two hands with respect to the clock centre.

import bpy
import bmesh
from math import pi, radians

context = bpy.context

ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)

def is_inline(vert, eps=1e-4):
    
    o = vert.co
    e0, e1 = v.link_edges
    v0 = e0.other_vert(vert).co - o
    v1 = e1.other_vert(vert).co - o
    return pi - v0.angle(v1) < eps

for v in bm.verts:
    v.select_set(
            len(v.link_edges) == 2
            and is_inline(v, eps=radians(2))
            )
            
bmesh.update_edit_mesh(me)
$\endgroup$
3
  • 1
    $\begingroup$ Man, I didn't have enough time to make 1000 $ bet that you'll be the one to post the solution and it will be a custom script :D $\endgroup$
    – michalpe
    Commented Jan 20, 2021 at 17:29
  • $\begingroup$ I guess the last value (following "eps=radians") determines the angle threshold and I'm not supposed to change anything else here, right? $\endgroup$
    – michalpe
    Commented Jan 20, 2021 at 17:30
  • $\begingroup$ Did you just write it or did you have it in your chest of drawers? I meant, chest of scripts. Do you have more scripts like this one? It's not the first time I came across your script on this forum, and it saved my day. $\endgroup$
    – michalpe
    Commented Jan 20, 2021 at 17:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .