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:
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:
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:
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:
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:
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:
Parameters:
| Parameter | Type | Description |
|---|---|---|
obj1, obj2, ... |
2D solids | Shapes to fill |
Examples:
minkowski
Compute the Minkowski sum of two objects. Conceptually, this "traces" one object around the surface of the other, useful for rounding edges.
Syntax:
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:
Parameters:
| Parameter | Type | Description |
|---|---|---|
obj1, obj2, ... |
solids or lists | Objects to concatenate |
Examples: