Utilities
Utility functions operate on Shape objects to create patterns, offsets, or composite forms.
grid
grid(shape, nx, ny, dx, dy) — Creates a rectangular grid of copies.
const peg = cylinder(3, 8);
const result = grid(peg, 4, 3, 15, 15); // 4 columns, 3 rows, 15mm spacing
| Parameter | Description |
|---|---|
shape |
Shape to duplicate |
nx |
Number of columns (X) |
ny |
Number of rows (Y) |
dx |
Spacing along X |
dy |
Spacing along Y |
ring
ring(shape, n, radius) — Arranges copies of a shape in a circle.
const peg = cylinder(3, 10);
const result = ring(peg, 8, 30); // 8 copies on a 30mm radius circle
hollow
hollow(shape, thickness) — Makes a shell by subtracting an inward-offset copy.
const result = hollow(sphere(20), 2); // 2mm wall thickness
hull
hull(...shapes) — Returns the convex hull enclosing all given shapes.
const result = hull(
sphere(5).translate([-20, 0, 0]),
sphere(5).translate([ 20, 0, 0]),
sphere(5).translate([ 0, 0,20]),
);
hull_chain
hull_chain(...shapes) — Creates a smooth bridge between consecutive pairs of shapes (loft-like).
const result = hull_chain(
cylinder(8, 1).translate([0, 0, 0]),
cylinder(4, 1).translate([0, 0, 10]),
cylinder(8, 1).translate([0, 0, 20]),
);
expand
expand(shape, offset, segs) — Inflates a shape by offset mm (positive = grow, negative = shrink).
const result = expand(box(20, 20, 5), 2); // rounded outer shell