I am trying to do programmatic modelling in blender using bmesh. I am using lists of vertices, finding edges and faces that connect them and performing various operations.

My issue is that once a vertex is altered in any way (e.g. it is moved, a new edge is added, etc.), it becomes dead and I can no longer perform operations on it.

Here is a basic example, (assuming bm is the bmesh of a primitive cube):

my_verts = [v for v in bm.verts]

bmesh.ops.subdivide_edges(bm, edges=bm.edges, cuts=1, use_grid_fill=True)


After the subdivide, every vertex in my_verts is dead.

How can I keep references to vertices that are preserved when operations are performed?

My thought so far are:

  • Keep references to the vertex positions and look them up every time (seems very hacky).
  • Maybe use layers in some way?

I would really appreciate some help on how this sort of thing is supposed to be done as it seems like it would be a fairly common problem when scripting modelling. Thank you.

  • 1
    $\begingroup$ This is XY problem. What exactly are you doing that needs you to know these vertices, so we can help you find a better solution than trying to solve this, when, maybe this is not even necessary. Vertex references get invalidated once you modify the bmesh, so you cannot store them or track them. I think the only way is to use a unique identifier related to each vertex like their coordinates, as they are guaranteed to be unique. Unfortunately, using coordinates may not be so reliable due to floating-point precision issues. $\endgroup$ Aug 9, 2023 at 6:01


Browse other questions tagged .