Skip to content

Boolean Operations

Boolean operations combine multiple solids using constructive solid geometry (CSG).

union

Combine multiple objects into one. The result contains all volume from all inputs.

Syntax:

union(obj1, obj2, ..., r=None, fn=None)
obj1 | obj2

Parameters:

Parameter Type Default Description
obj1, obj2, ... solids Objects to combine
r float Fillet radius for newly created edges (PythonSCAD extension)
fn int Number of segments for fillet rounding (PythonSCAD extension)

PythonSCAD extensions:

Specifying r and fn adds rounded fillets to the edges created by the union:

from openscad import *

union(cube(10), sphere(7).right(5), r=1, fn=10).show()

Examples:

from openscad import *

union(cube(10), sphere(7)).show()

# Operator form
(cube(10) | sphere(7)).show()

OpenSCAD reference: union


difference

Subtract one or more objects from the first object.

Syntax:

difference(obj1, obj2, ..., r=None, fn=None)
obj1 - obj2

Parameters:

Parameter Type Default Description
obj1 solid Base object
obj2, ... solids Objects to subtract
r float Fillet radius for newly created edges (PythonSCAD extension)
fn int Number of segments for fillet rounding (PythonSCAD extension)

Examples:

from openscad import *

difference(cube(10), sphere(7)).show()

# Operator form
(cube(10) - sphere(7)).show()

# With filleted edges
difference(cube(10), cylinder(r=4, h=12, center=True), r=0.5, fn=8).show()

OpenSCAD reference: difference


intersection

Keep only the volume that is common to all input objects.

Syntax:

intersection(obj1, obj2, ...)
obj1 & obj2

Parameters:

Parameter Type Description
obj1, obj2, ... solids Objects to intersect

Examples:

from openscad import *

intersection(cube(10), sphere(7)).show()

# Operator form
(cube(10) & sphere(7)).show()

OpenSCAD reference: intersection


hull

Create the convex hull of multiple objects. The result is the smallest convex solid that contains all input objects.

Syntax:

hull(obj1, obj2, ...)
obj1 ^ obj2

Parameters:

Parameter Type Description
obj1, obj2, ... solids Objects to hull

Examples:

from openscad import *

hull(cube(3), sphere(2).right(10)).show()

# Operator form
(cube(3) ^ sphere(2).right(10)).show()

OpenSCAD reference: hull


fill

Fill concavities in a 2D shape, creating a convex outline.

Syntax:

fill(obj1, obj2, ...)

Parameters:

Parameter Type Description
obj1, obj2, ... 2D solids Shapes to fill

Examples:

from openscad import *

fill(polygon([[0,0], [10,0], [5,3], [10,10], [0,10]])).show()

minkowski

Compute the Minkowski sum of two objects. Conceptually, this "traces" one object around the surface of the other, useful for rounding edges.

Syntax:

minkowski(obj1, obj2, convexity=2)
obj1 % obj2

Parameters:

Parameter Type Default Description
obj1 solid Base object
obj2 solid Object to trace around obj1
convexity int 2 Convexity for rendering

Examples:

from openscad import *

# Round the edges of a cube
minkowski(cube(10), sphere(1)).show()

# Operator form
(cube(10) % sphere(1)).show()

OpenSCAD reference: minkowski


concat

Concatenate the meshes of multiple objects without performing boolean operations. This is useful when sub-parts are not yet watertight and CSG would fail.

Syntax:

concat(obj1, obj2, ...)

Parameters:

Parameter Type Description
obj1, obj2, ... solids or lists Objects to concatenate

Examples:

from openscad import *

alltogether = concat(part1, part2, part3)
alltogether.show()