“Cannot execute boolean operation” when subtracting several spheres and cylinders from cube This is a follow-on question as suggested by a commenter. What I'd like to do is to create a geometry with the following properties:

A cube with several spherical indentations carved out on top. 16 indentations are half-spheres. The 17th indentation has the shape of four half-cylinders that form a ring (with slightly rounded corners corresponding to the radius of the cylinders).

My plan of attack is as follows:


create and scale the cube
create 16 spheres clustered around the center of the cube's top face
create 4 cylinders, scale and rotate them to form the basic ring
create 4 more spheres at the corners to complete the ring
add 16 DIFFERENCE boolean modifiers to the cube with the 16 spheres from step 2 as targets; hide each sphere after adding the corresponding modifier
add 4 DIFFERENCE boolean modifiers to the cube with the 4 cylinders from step 3 as targets; hide each cylinder after adding the corresponding modifier
add 4 DIFFERENCE boolean modifiers to the cube with the 4 spheres from step 4 as targets; hide each sphere after adding the corresponding modifier


Steps 1 + 2 work as expected:



Steps 3 + 4 also work as expected:



And so does step 5:



And even step 6 for the 1st cylinder:



However when I try to subtract the 2nd cylinder the visual result is unexpected and the error message appears:





What is going on here and how can I obtain the desired geometry? 

Could the problem be caused by the fact that the two cylinders I wish to subtract from the cube are themselves overlapping? (The Blender documentation mentions "concurrent Boolean operations for the same modified mesh, which in most cases is impossible to execute depending on the chosen target" but does not elaborate further.)

UPDATE Here's the (still expected) result when joining the 4 cylinders and last 4 spheres before subtracting the from the cube (see @Polosson's comment):
Cases where boolean operations can fail:


Overlapping geometry between objects:
Multiple vertices in the same location will often cause the boolean modifier to act up.
From this bug report:


  this is a known bug in Carve upstream (a library we're using for boolean operations)

Self intersecting objects:
Boolean operations with non-manifold objects or objects that are not water-tight will fail when non-manifold parts interact in the boolean operation.


Some things you can try:

Add supporting geometry. The boolean operation creates a lot of tris, so this might make subsequent operations difficult.

For example:

The spheres boolean causes this mess of tris where the cylinders will go:



However, if you add some loop cuts around the spheres:



The tris are contained in the center, keeping the topology clean where the cylinders intersect:



With modeling tools

You can get the result with conventional modeling too:


Add a sphere and two cylinders (the cylinders are just guides)
Rotate and move then into position using increment snapping (Ctrl) to keep everything precisely aligned:


Snap the 3D cursor to the sphere object by selecting (in object mode) it and pressing ShiftS> Cursor to Selected
Press . (period) to set the pivot to the 3D cursor
Enter edit mode with the sphere active and delete these elements with X or Delete> Vertices:


Scale the 45 degree edgeloop along the X and Y by pressing S and then ShiftZ, then holding Ctrl to snap until the edgeloop at 45 degrees touches the intersection at the two cylinders:



The cylinders are no longer useful after this step, so you can delete them.
Select the vertices as shown:


Extrude along the X axis (EX):


Set the pivot to Bounding box center (,) and scale the selection to 0 along the X by pressing SXO (zero):


Do the same for the other side:


Add a mirror modifier and enable X and Y:


With the sphere active, enter edit mode and select all (A), then move it so the object origin is not in the middle of the sphere:


Before:


After:



Enable Clipping in the mirror modifier and move each edge so it merges with the mirrored geometry:




You can then use this for the boolean operations:



Here is the blendfile.