# Problem with Boolean-difference modifier – or – How to model a cuboid with two cylindric holes

Simplified: I want to generate a cuboid with cylinders as holes in Blender. When I add with a difference-modifier, I come to pretty common problems/limitations.

There are lots of tips or advice like about this theme: - Solidify the objects before booleaning them - Recalculating normals - Close holes I couldn’t fix the problem with this general advice. I know that these are the limitations of face-based modelling (with Blender) and not volume-based (other software) modelling. But there must be a work around for Blender? I know a manual fix for this problem:

By manually and step adding the faces (in the Edit Mode by selection one edge and pressing [enter])

Well at least it is nearly a solution…

But anyway, this isn't helpful for a scripted solution... So what can I do? Can someone tell me how to code this?

# code Example of this Problem for Blender 2.80b (warning, this seems to be not backwards compatible with Blender 2.79):

#code for Blender 2.80
import bpy

def booleanModifierApplyAndDelete(fromObject, removeObject):
##Switch to
bpy.ops.object.select_all(action='DESELECT')
bpy.context.view_layer.objects.active = bpy.data.objects[fromObject]
bpy.data.objects[fromObject].select_set(state=True)

##addModifier Working
bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].operation = 'DIFFERENCE'
bpy.context.object.modifiers["Boolean"].object = bpy.data.objects[removeObject]
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
bpy.data.objects.remove(bpy.data.objects[removeObject], do_unlink=True)

#initial variables:

thickness = 2
width = 5
height = 2
overlap = 0.1

#delete all objects from previous Build
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)

##add mainCube
bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(0,0,0))
bpy.context.active_object.name = 'mainCube'
bpy.context.object.dimensions = (thickness,width,height)

#top Rounding/hole
bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=1-overlap/2*2, depth=width+overlap*2, view_align=False, enter_editmode=False, location=(0, 0, 1), rotation=(1.5708, 0, 0))
bpy.context.active_object.name = 'topRounding'

booleanModifierApplyAndDelete('mainCube', 'topRounding')

#cylindrical hole
bpy.ops.mesh.primitive_cylinder_add(vertices=64, depth=height+overlap*2, view_align=False, enter_editmode=False, location=(0, 0, 0))
bpy.context.active_object.name = 'hole'

booleanModifierApplyAndDelete('mainCube', 'hole')

• Have you tried adding subdivisions/more edge loops to the original mesh? That can sometimes help. – Sazerac Mar 19 at 23:31

## 2 Answers

I think this is the simplest way, without code, in Blender 2.80 Beta. I use the Bool Tool activated in the Add-ons in the Preferences.

1. Select the 2 cylinders, press n to bring up the panel, if not showing, and click on the Tools tab to show the Bool Tools.

1. Union them, now you have only one cylinder object, see below.

1. With this latest cylinder selected, add the cube to the selection and Difference them. Now you have the desired object shape.

• Thank you. My Beta version wasn't containing the Bool Tools in the Settings. So i downloaded the latest version. I tried to reproduce every step... The N key just opend the Objectmenu, so i used [strg]+[shift]+[B]. But i could not reproduce your result and was left with the open surface like before (the second picture in the question). – gjm Mar 20 at 15:39
• Okay, there seems to be a problem with the modifier, when the axis of the cylinder is located exactly in the surface of the cube. When I slightly move the cylinder, it works just fine. – gjm Mar 20 at 15:56
• May need to report it as a bug then. Must have been a really old beta. The Bool Tool is part of the beta for a while. For the 'n' key to work you need to hover your cursor over the modeling window you are working on. Feel free to mark my answer as a solution if it solved your problem. – Sprad001 Mar 21 at 4:01
• Forgot to mention, to report a bug go to the Help menu and select Report a Bug menu item. The guys are very responsive there. If it is found to be a bug, they will resolve it in a few days, that is my experience. Give as much information as you can, if possible with images or sample blender file that has the problem and a very clear explanation. – Sprad001 Mar 21 at 4:05

Because an intersection between two cylinders is a 45 degree miter, this isn't too hard to model. Z up, Y along the lenght, X across

1. K with C to constrain and Z to cut through, make 2 45 degree cuts into a half-cylinder as shown
2. E (right-click to cancel transform) followed by SX extrude the long edges outwards
3. Select all the faces, E extrude them downwards, followed by SZ0 about their median point to flatten them.
4. Select the central hole-faces on both sides, and CtrlE > Bridge Edge Loops
5. Header select menu > Select Sharp Edges, and add some by hand to complete the circumference of the top hole. Set the Bevel Weight of all the selected edges to 1.00

Assign a Bevel modifier by Weight, Segments 2, Profile 1.00. I usually switch off the clamps, and reduce the width until everything looks correct. Assign a Subdivision Surface modifier.