Primitives
Primitive constructors return a Shape object centered at the origin (Z-up).
box
box(w, d, h) — Rectangular box centered at origin.
const result = box(40, 30, 10);
| Parameter | Description |
|---|---|
w |
Width along X |
d |
Depth along Y |
h |
Height along Z |
cylinder
cylinder(r, h, segs=32) — Cylinder centered at origin, axis along Z.
const result = cylinder(10, 30); // r=10, h=30
const result = cylinder(10, 30, 64); // smoother
cone
cone(r, h, segs=32) — Cone with base radius r, tip at top, centered at origin.
const result = cone(8, 20);
sphere
sphere(r, segs=32) — Sphere centered at origin.
const result = sphere(15);
const result = sphere(15, 64); // smoother
torus
torus(innerR, outerR) — Donut shape in the XY plane, centered at origin.
const result = torus(5, 15); // tube radius 5, ring radius 15
rounded_box
rounded_box(w, d, h, r) — Box with rounded vertical edges.
const result = rounded_box(40, 30, 10, 3); // 3mm radius
chamfer_box
chamfer_box(w, d, h, c) — Box with chamfered (45°) vertical edges.
const result = chamfer_box(40, 30, 10, 2); // 2mm chamfer
hole_chamfer
hole_chamfer(r, h, c) — Cylindrical hole tool with a chamfered entry, ready to subtract from a box.
const base = box(40, 40, 10);
const hole = hole_chamfer(4, 10, 1.5); // r=4, h=10, chamfer=1.5mm
const result = base.sub(hole);