0
$\begingroup$

I have a Python script in which I get the BMesh from an existing mesh. Then I want to get the outer edges of the mesh, not the inner edges, mesh could for instance look like this:

enter image description here

I want to get the edges as a sequence that are not in the inside.

Thx for your help.

Edit: Can get the outer edges now like that:

bm = bmesh.from_edit_mesh(obj.data)

outer_edges = [edge for edge in bm.edges if edge.is_boundary]

for edge in outer_edges:
    vertices.append(edge.verts[0])

The only problem I have now is that I want to order them clockwise, any idea for this?

Edit 06.11.2020: Ok ended up with this one here:

bm = bmesh.from_edit_mesh(obj.data)
bm.verts.ensure_lookup_table()

vert = bm.verts[0]
prev = None

for i in range(len(bm.verts)):
    next = None
    for v in [e.other_vert(vert) for e in vert.link_edges if e.is_boundary]:
        if (v != prev):
            next = v

    vertices.append(obj.matrix_world @ vert.co)

    if next == None:
        break
    
    prev, vert = vert, next
$\endgroup$
7

Browse other questions tagged or ask your own question.