Suppose I have identified or can identifiy some meshparts I no longer want in my mesh and want to delete them, how would I do it?

I know that bmesh.ops.delete exists, I just don't know how to use it, because the API is a bit lacking for that function. :)



using the bmesh simple template from the text editor, and a bit of snooping around. You should experiment with the geom and context parameters.

The context is enumerated so (source: bmesh_operator_api.h):

enum {

This example assumes we have a mesh object in edit-mode and several faces selected. Running the script will delete edges and faces associated with the selection.

import bpy
import bmesh

# Get the active mesh
obj = bpy.context.edit_object
me = obj.data

# Get a BMesh representation
bm = bmesh.from_edit_mesh(me)
faces_select = [f for f in bm.faces if f.select] 

bmesh.ops.delete(bm, geom=faces_select, context=5)  

# Show the updates in the viewport
# and recalculate n-gon tessellation.
bmesh.update_edit_mesh(me, True)
| improve this answer | |
  • $\begingroup$ What are the differences between DEL_ONLYFACES, DEL_EDGESFACES and DEL_FACES? $\endgroup$ – Peter Hilgers Nov 14 '16 at 16:44
  • $\begingroup$ those are the same options you get if you try to delete geometry using X in the viewport, ONLYFACES keeps edges (and verts), EDGESFACES just keeps verts, ...etc.. $\endgroup$ – zeffii Nov 14 '16 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.