I wrote an addon that removes components (using BMesh) depending on the context of the selection. The problem is that he crashes a Blender. I cannot establish a pattern, but most often this happens after several operations in the Edit mode and an attempt to delete all the polygons or n-gon. If I try to repeat the same operations, everything can go well.
since the polygon delete causes the problem, I think in this part of the code:
import bpy import bmesh def delete_components(): # for components selection mode obj = bpy.context.edit_object # prepearing BMesh variables me = obj.data bm = bmesh.from_edit_mesh(me) sel_faces = [s for s in bm.faces if s.select] # get the list of selected polygons if bpy.context.edit_object.type == 'MESH': # if mesh is selected sel_mode = bpy.context.tool_settings.mesh_select_mode[:] # define active selection modes if sel_mode == True: # if polygon selection mode is on for f in sel_faces: # unselect all edges belonging to these polygons for e in f.edges: e.select = False bmesh.ops.delete(bm, geom=sel_faces, context = "FACES") # delete polygons bmesh.update_edit_mesh(me, True) #update BMesh mesh delete_components()
link to the full code: https://github.com/Borschberry/smart_delete
p.s. This is my first addon and I just started working in Blender. Correct me if I incorrectly described the problem.