I'm trying to use a boolean modifier to difference two objects. This works, but what it creates is incomplete vs what happens in blender itself.
Here's relevant code:
def difference(self, source_object, modifier_object): ## select the object bpy.ops.object.select_all(action = 'DESELECT') bpy.context.scene.objects.active = source_object ## add the boolean modifier to the selected object and apply it. bpy.ops.object.modifier_add(type='BOOLEAN') bpy.context.object.modifiers["Boolean"].operation = 'DIFFERENCE' bpy.context.object.modifiers["Boolean"].object = modifier_object bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean") modifier_object.hide = True ## hide the second object
If I call this with a cube and a sphere, the sphere is "cut" from the cube as expected, but there's a hole in the cube instead of a complete surface. What am I doing wrong? I've looked at a few different answers, for example using object.modifier.new -- but none have worked so far.