OpenSCAD Boolean Operations example

OpenSCAD examples
/

Boolean Operations

Beginner

Foundations

Lesson 6 of 22

Compare union, difference, and intersection using genuinely separate child solids.

Try changing:

stepcube_sizesphere_radiussphere_offset

Medium 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.

  1. Inspect the two operands · Operands

    The cube and sphere are laid apart so both complete input solids are visible. The following operations restore the sphere_offset between their centers.

  2. Fuse · Union

    Keep every point inside either input. The sphere protrudes from the cube.

  3. Subtract · Subtract

    Keep points inside the cube but outside the sphere. Inspect the exposed concave scoop.

  4. Keep the overlap · Intersect

    Keep only points inside both inputs. This is exactly the material removed from the cube in the previous step.

  5. Compare the results · Compare

    Show union, subtraction, and intersection from left to right. Subtraction volume plus intersection volume equals the original cube volume.

main.scad

Loading draft

Ctrl/Cmd+Enter or F5: preview · F6: render · Ctrl/Cmd+F: search · Ctrl+Space: complete · Tab: leave editor

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.

FAQ