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
  • 1
    $\begingroup$ blender.stackexchange.com/questions/47192/select-mesh-perimeter $\endgroup$ Commented Nov 3, 2020 at 7:46
  • 1
    $\begingroup$ @batFINGER Oh, that simple:-) Thx $\endgroup$ Commented Nov 3, 2020 at 7:49
  • 1
    $\begingroup$ NP, Also Somewhat related blender.stackexchange.com/questions/108830/… $\endgroup$ Commented Nov 3, 2020 at 7:51
  • $\begingroup$ @batFINGER Works to get the outer edges, now I need to reorder them clockwise, any idea? Edited the question. $\endgroup$ Commented Nov 3, 2020 at 8:17
  • 2
    $\begingroup$ Baulked on closing in first place re this. Search is down for maintenance atm have used this answer blender.stackexchange.com/a/110996/15543 to get edge loops, blender.stackexchange.com/a/197371/15543 could use similar for edge ring. If you get one edge, its verts are wound counter clockwise to face normal. Use to get initial direction then walk edge.other_vert(v).linik_edges until back to start. Sure have answered this before too. (posted other link as it walks corner to corner) $\endgroup$ Commented Nov 3, 2020 at 8:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.