I am trying to fix a bug in my script that happens in rare instances. I believe the bug occurs due to the very last thing the script is doing, which is:

bmesh.ops.remove_doubles(bm, verts=verts_to_weld, dist=0.001)

I think the problem is that verts_to_weld refers to a list of BMVerts that contains dead elements. This is because earlier in the script I use bmesh.ops.delete() to get rid of inner faces after using bmesh.ops.extrude_face_region(). So essentially my Remove Doubles is referring to some vertices that have been deleted earlier and don't exist in my bmesh anymore, but are still in the list. Is there a way to take the list verts_to_weld and remove any dead verts from that list? Thanks! Here's what my error looks like and also the print(verts_to_weld) at the bottom:

Error and printed list of verts_to_weld


2 Answers 2


Look at the is_valid property of a bmesh element.

In this case you have verts in your list that are no longer valid. Use BMVert.is_valid to check.


        verts=[v for v in verts_to_weld if v.is_valid],

From the print output, it looks like the 'dead' vertices don't have any index associated with them. Did you try iterating through the list - verts_to_weld - and removing vertices with index == None? Or maybe print the index of all the vertices in the list and see what it is for dead vertices. Most likely it won't be an int.

  • $\begingroup$ Very, very unlikely an int property is no longer an int. See the documentation BMVert.index Dead bmesh elements are marked as invalid eg is_dead = not vert.is_valid $\endgroup$
    – batFINGER
    Oct 16, 2018 at 11:36
  • $\begingroup$ @batFinger I tried checking the is_valid flag of the deleted verts. But they had it set to True. That's the reason I thought it could be determined through the index. Maybe I missed something while making the delete call. $\endgroup$ Oct 16, 2018 at 14:00
  • $\begingroup$ The v.is_valid works perfectly for me. $\endgroup$ Oct 17, 2018 at 0:26
  • $\begingroup$ @z01ks Glad to know that :) $\endgroup$ Oct 17, 2018 at 4:30

You must log in to answer this question.

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