enter image description here

I have a mesh object that I would like to script an operation on. I know how how to do it manually, I just can't figure out how to script it.

If you open the file attached, you should see the letter "g" with two faces. If you select the figure, go into edit mode, turn on face selection, select the index 1 face, and then go to face -> Intersect (Boolean). Make sure that Boolean Operation is set to Union, the solver exact, and everything unchecked. Doing this fixed the mesh to how I want it.

I see that bpy.ops.mesh.intersect_boolean(operation='UNION', use_swap=False, use_self=False, solver='EXACT') appears below the console. I also believe that if you want to perform mesh operations, you can't use bpy.ops.mesh, you have to use bmesh.ops. I have searched through bmesh.ops and I cannpt find intersect_boolean. This is where I need help. I wish bmesh.ops had a function such as bmesh.ops.boolean_intersect(bm, bm.faces[1])

If there are any other ways to fix the mesh, that would be great, as long as it runs fast. I know that modifiers can slow things down at times.


1 Answer 1


When I run Intersect(Boolean) as you wrote to your object, the left geometry is created (2.91.0).

enter image description here

If you really want it that way, the same result on the right side by script.

import bpy

obj = bpy.data.objects["Figure"]
bpy.context.view_layer.objects.active = obj # active object

obj.data.polygons[1].select = True  # this needs Objectmode

bpy.ops.mesh.intersect_boolean(operation='UNION', use_swap=False, use_self=False, solver='EXACT')  # this needs Editmode

You need to use bpy.ops.mesh.intersect_boolean, as far as I know. For the selection of faces you can use bmesh too. Best to read this post I think: select-specific-face-by-its-index

  • $\begingroup$ I'm using 2.93.5 and the Intersect Boolean with specified parameters gives me just the border of the letter. No weird polygons for me. Your code also worked fine for me :) $\endgroup$ Nov 14, 2021 at 22:28

You must log in to answer this question.

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