Selecting and deleting faces introduces from boolean cut

I am creating an add on. I would like to code a way to delete the faces caused by a boolean cut. I have to use as little “hard coding” as possible because this function will have multiple uses. I will upload a picture of the faces I want to delete. Even if someone can’t help structure the code, even some pseudo code of steps to achieve this would be helpful. I thought about trying to assign those vertices to a vertex group but it did not work.

so I figured out that if directly after you do the boolean cut, then switch into edit mode and delete faces that they are already hilighted so it works great, just play around with the order of your cuts. I will put a snippet of my code below:

head = bpy.data.objects[‘headmesh’]
face = bpy.data.objects[‘face_cutout’]
bottom = bpy.data.objects[‘bottom_cutout’]

    bpy.ops.object.mode_set(mode='OBJECT')
    bool_two = head.modifiers.new(type="BOOLEAN", name="bool 2")
    bool_two.object = bottom
    bool_two.operation = 'DIFFERENCE'
    bottom.hide_set(True)
    bpy.context.view_layer.objects.active = head
    bpy.ops.object.modifier_apply(modifier="bool 2")

    bpy.context.view_layer.objects.active = head
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.delete(type='FACE')

    bpy.ops.object.mode_set(mode='OBJECT')
    bool_one = head.modifiers.new(type="BOOLEAN", name="bool 1")
    bool_one.object = face
    bool_one.operation = 'DIFFERENCE'
    face.hide_set(True)
    bpy.context.view_layer.objects.active = head
    bpy.ops.object.modifier_apply(modifier="bool 1")
    bpy.context.view_layer.objects.active = head
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.delete(type='FACE')

I would personally create a bvh tree of the operand mesh before the boolean, then do an overlap test afterward

Just a thought: if the original object and the "cutting object* have different materials… then the inner faces do have the material of the cutting object… so maybe just selecting by that material and delete would be “easier” ??

( or maybe not if they are alrady selected… :sweat_smile: )