JS Functions Overview

All functions return a Shape object that supports chaining. The coordinate system is Z-up (X=right, Y=front, Z=up).

Primitive shapes

Function Description
box(w, d, h) Rectangular box
cylinder(r, h, segs=32) Cylinder along Z axis
cone(r, h, segs=32) Cone along Z axis
sphere(r, segs=32) Sphere
torus(innerR, outerR) Torus (donut)
rounded_box(w, d, h, r) Box with rounded edges
chamfer_box(w, d, h, c) Box with chamfered edges

Boolean operations

a.add(b)        // Union
a.sub(b)        // Difference
a.intersect(b)  // Intersection

Transformations

shape.translate([x, y, z])
shape.rotate([rx, ry, rz])   // degrees
shape.scale([sx, sy, sz])    // or .scale(s) for uniform

Free shapes

polygon([[x,y], ...], height)
extrude([[x,y], ...], height, { twist: 45 })
revolve([[x,y], ...], segs=64)              // centered at origin
revolve([[x,y], ...], 64, { center: false }) // base at z=0

Utilities

grid(shape, nx, ny, dx, dy)      // Grid of copies
ring(shape, n, radius)           // Circular array
hull(...shapes)                  // Convex hull

Returning the result

Always assign your final shape to const result. Parameter IDs (e.g. width) are available directly as variables — no params.width needed.

// width, depth, height defined in the Parameters tab
const result = box(width, depth, height);