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

enter image description here

And then execute a fill.

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


  • 3
    $\begingroup$ The selection here is vertices that are on edges which themselves correspond to only one face. $\endgroup$
    – lemon
    Jan 27, 2020 at 6:25
  • 2
    $\begingroup$ 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? $\endgroup$
    – Jayanam
    Jan 27, 2020 at 6:33
  • 2
    $\begingroup$ Yes link_faces with a count of 1. $\endgroup$
    – lemon
    Jan 27, 2020 at 6:40
  • 2
    $\begingroup$ Which is also edge.is_boundary $\endgroup$
    – batFINGER
    Jan 27, 2020 at 7:57
  • $\begingroup$ @batFINGER: That's it - thx a lot $\endgroup$
    – Jayanam
    Jan 27, 2020 at 12:16

1 Answer 1


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.             


Similarly with the edge loop fill operator

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

You must log in to answer this question.

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