OpenSCAD Boolean Operations example
Foundations
Lesson 6 of 22
Compare union, difference, and intersection using genuinely separate child solids.
Try changing:
stepcube_sizesphere_radiussphere_offsetMedium compile complexity. Three curved booleans; difference should visibly differ from both neighbors.
Visual walkthrough: change step in the workspace Parameters panel to compile each construction stage.
How this model works
Each boolean receives the cube and sphere as two direct children. A module that emits both primitives is implicitly unioned when called as a single child: difference() blocks() and intersection() blocks() would therefore both receive only one solid and incorrectly resemble the union. Here the sphere is deliberately offset so the subtraction is an obvious open scoop, rather than an enclosed cavity.
Inspect the two operands ·
OperandsThe cube and sphere are laid apart so both complete input solids are visible. The following operations restore the sphere_offset between their centers.
Fuse ·
UnionKeep every point inside either input. The sphere protrudes from the cube.
Subtract ·
SubtractKeep points inside the cube but outside the sphere. Inspect the exposed concave scoop.
Keep the overlap ·
IntersectKeep only points inside both inputs. This is exactly the material removed from the cube in the previous step.
Compare the results ·
CompareShow union, subtraction, and intersection from left to right. Subtraction volume plus intersection volume equals the original cube volume.
main.scad
Loading draft
Ready
Z up · geometry preview
Your geometry will appear here
Preview or render the model to inspect it in 3D.
Geometry-only STL preview
Grid 10 units · Drag: orbit · Right-drag / two fingers: pan · Scroll / pinch: zoom
0 messages
Make it your own
Change sphere_offset to zero and compare the three silhouettes. Then swap the two children of difference: subtraction order matters, but union and intersection order do not.
Change one parameter at a time and inspect the result. Use the workspace reset action to return to this lesson’s original model.