# Select first and last edge loop

I want to fill the holes of a mesh created from a curve programmatically, so my idea was to select the first and last edgeloop with Python

And then execute a fill.

So my question is: How to select the first and last ring of the mesh in code?

Thx

• The selection here is vertices that are on edges which themselves correspond to only one face. – lemon Jan 27 at 6:25
• Ok, but I dont see how this answers my question, or at least how to find this out in code (BMesh). Or wait a moment: link_faces is the sequence of faces connected to the edge, so the count must be 1 right? – Jayanam Jan 27 at 6:33
• Yes link_faces with a count of 1. – lemon Jan 27 at 6:40
• Which is also edge.is_boundary – batFINGER Jan 27 at 7:57
• @batFINGER: That's it - thx a lot – Jayanam Jan 27 at 12:16

Contextual Create operator

For the case given, simply finding all the boundary edges and spitting into contextual create operator ngon fills the edge loops

The edges of the returned faces are the original edge loops Use to fill other than ngon.

import bpy
import bmesh

context = bpy.context
ob = context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)

ret = bmesh.ops.contextual_create(bm,
geom=[e for e in bm.edges if e.is_boundary])

# the seperate edge loops
edge_loops = [f.edges[:] for f in ret["faces"]]
# if don't like the ngon fill then do something here
# eg remove face
# grid fill edge loops,
# poke face for tri fan.

bmesh.update_edit_mesh(me)


Similarly with the edge loop fill operator

ret = bmesh.ops.edgeloop_fill(bm,
edges=[e for e in bm.edges if e.is_boundary])