0

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

Jayanam
  • 665
  • 3
  • 18
  • 1
    https://blender.stackexchange.com/questions/47192/select-mesh-perimeter – batFINGER Nov 03 '20 at 07:46
  • 1
    @batFINGER Oh, that simple:-) Thx – Jayanam Nov 03 '20 at 07:49
  • 1
    NP, Also Somewhat related https://blender.stackexchange.com/questions/108830/how-to-find-a-side-total-length – batFINGER Nov 03 '20 at 07:51
  • @batFINGER Works to get the outer edges, now I need to reorder them clockwise, any idea? Edited the question. – Jayanam Nov 03 '20 at 08:17
  • 2
    Baulked on closing in first place re this. Search is down for maintenance atm have used this answer https://blender.stackexchange.com/a/110996/15543 to get edge loops, https://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) – batFINGER Nov 03 '20 at 08:38
  • https://blender.stackexchange.com/questions/191649/how-can-i-sort-vertex-positions-sequentially-indices-in-a-closed-area could also use https://blender.stackexchange.com/questions/186067/what-is-the-bmesh-equivalent-to-bpy-ops-mesh-shortest-path-select/186137 (narrowing down selection to boundary edges) – batFINGER Nov 03 '20 at 08:51
  • @batFINGER : Ok, thx worked with walking over link_edges, my algo is in the description, thx! – Jayanam Nov 06 '20 at 19:00

0 Answers0