Boolean Operations
Combine, subtract, and intersect shapes to create complex geometries
Overview
Boolean operations are fundamental to constructive solid geometry (CSG) modeling. They allow you to combine multiple shapes in different ways to create complex forms. Conjure supports three primary boolean operations: union, cut (subtraction), and intersection.
These operations work on any solid shapes, including primitives and previously created complex geometries. Boolean operations are non-destructive - the original shapes remain available for further operations.
Commands
union
Combines two or more shapes into a single unified shape. The resulting shape includes all the volume from all input shapes, with overlapping regions merged together.
Parameters:
shapes- List of shape objects to combine
Use Cases:
- Joining separate parts into a single component
- Adding features or protrusions to a base shape
- Creating complex forms from simple primitives
// Combine two boxes
box1 = create_box(30, 30, 10)
box2 = create_box(10, 30, 30)
box2 = translate(box2, 10, 0, 0)
combined = union(box1, box2)
// Union multiple shapes
base = create_cylinder(radius=20, height=5)
pillar1 = create_cylinder(radius=3, height=50)
pillar1 = translate(pillar1, 10, 0, 5)
pillar2 = create_cylinder(radius=3, height=50)
pillar2 = translate(pillar2, -10, 0, 5)
structure = union(base, pillar1, pillar2)
cut
Subtracts one or more shapes from a base shape. The volume of the cutting shapes is removed from the base shape, creating holes, pockets, or negative features.
Parameters:
base_shape- The primary shape to cut fromcutting_shapes- Shape(s) to subtract from the base
Use Cases:
- Creating holes for bolts, pins, or shafts
- Hollowing out solid shapes
- Making pockets and recesses
- Creating threaded features
// Create a box with a hole through it
base = create_box(50, 50, 20)
hole = create_cylinder(radius=10, height=25)
hole = translate(hole, 25, 25, -2)
result = cut(base, hole)
// Create multiple holes in a plate
plate = create_box(100, 100, 5)
hole1 = create_cylinder(radius=4, height=6)
hole1 = translate(hole1, 20, 20, -0.5)
hole2 = create_cylinder(radius=4, height=6)
hole2 = translate(hole2, 80, 20, -0.5)
hole3 = create_cylinder(radius=4, height=6)
hole3 = translate(hole3, 20, 80, -0.5)
hole4 = create_cylinder(radius=4, height=6)
hole4 = translate(hole4, 80, 80, -0.5)
drilled_plate = cut(plate, hole1, hole2, hole3, hole4)
intersect
Creates a shape from the overlapping volume of two or more shapes. Only the region where all input shapes overlap is kept in the result.
Parameters:
shapes- List of shape objects to intersect
Use Cases:
- Creating complex shapes from simple intersections
- Trimming shapes to fit within boundaries
- Making chamfers and bevels
- Creating precise fits between components
// Create a rounded cube by intersecting a sphere and box
box = create_box(40, 40, 40)
sphere = create_sphere(radius=30)
sphere = translate(sphere, 20, 20, 20)
rounded = intersect(box, sphere)
// Create a lens shape from two spheres
sphere1 = create_sphere(radius=25)
sphere2 = create_sphere(radius=25)
sphere2 = translate(sphere2, 20, 0, 0)
lens = intersect(sphere1, sphere2)
Operation Order
Boolean operations can be chained together to create complex models. The order of operations matters:
// Example: Creating a bracket
// Step 1: Create the base plate
base = create_box(60, 40, 5)
// Step 2: Add mounting tabs (union)
tab1 = create_box(10, 15, 5)
tab1 = translate(tab1, -10, 12.5, 0)
tab2 = create_box(10, 15, 5)
tab2 = translate(tab2, 60, 12.5, 0)
bracket = union(base, tab1, tab2)
// Step 3: Add vertical support
support = create_box(60, 5, 30)
support = translate(support, 0, 40, 0)
bracket = union(bracket, support)
// Step 4: Cut mounting holes (cut from the unified shape)
hole1 = create_cylinder(radius=3, height=6)
hole1 = translate(hole1, -5, 20, -0.5)
hole2 = create_cylinder(radius=3, height=6)
hole2 = translate(hole2, 65, 20, -0.5)
bracket = cut(bracket, hole1, hole2)
// Step 5: Add a lightening hole in the base
large_hole = create_cylinder(radius=15, height=6)
large_hole = translate(large_hole, 30, 20, -0.5)
bracket = cut(bracket, large_hole)
Performance Tips
- • Boolean operations can be computationally expensive on complex shapes. Consider simplifying geometry when possible.
-
•
Multiple unions can often be performed in a single operation rather than chaining:
union(shape1, shape2, shape3)is more efficient thanunion(union(shape1, shape2), shape3) - • For many identical features (like holes), use arrays or patterns rather than individual operations
- • Intersection operations can fail if shapes don't actually overlap - ensure proper positioning
Troubleshooting
Common Issues:
Boolean operation fails or produces unexpected results
This often happens when shapes have coincident faces or edges. Try slightly enlarging cutting shapes or adding small offsets to avoid exact overlaps.
Intersection returns empty shape
The shapes don't overlap. Check positioning with measure() commands or verify transforms are applied correctly.
Performance issues with many boolean operations
Consider using parametric features like pockets and holes instead of boolean operations where possible. Reduce model complexity before performing booleans.