Make and edit a solid plate
Start with cad.model(), give dimensions names, and build a named native Solid. All values are millimetres. No document version, native IDs or revision counters are needed.
import { cad, CadModelError, type CadModelSnapshot } from '@barocss/cad';export function makePlate() {
const m = cad.model();
const width = m.parameter('width', 32);
const depth = m.parameter('depth', 16);
const height = m.parameter('height', 8);
const plate = m.sketch.rectangle({ width, height: depth }).extrude(height);
return m.build({ part: plate });
}makePlate() returns an immutable accepted snapshot. Its bodies.part is the actual native Solid. width and depth describe the XY rectangle; height is its positive Z extrusion. A build evaluates every authored operation and requires at least one named output.
Edit, save and reopen
export function editPlate() {
const original = makePlate();
const edited = original.withParameters({ width: 24, height: 6 });
const authoredText = edited.save();
const reopened = cad.load(authoredText);
return reopened.withParameters({ width: 32 });
}This function uses the imports and makePlate function above. Narrow editPlate().bodies.part.family to convex-planar, then read its native.certificate.volumeMM3 for the exact native volume. withParameters returns a new snapshot only after the whole candidate succeeds. Keep original or the last accepted snapshot if an edit throws CadModelError; no partial candidate is accepted. save() returns authored text, and cad.load() rebuilds it. Your application owns storage and file dialogs.
Next: cut and chamfer a part
Continue with the complete modeling guide for a convex polygon, through-slab cut, unique edge selection, real component chamfer, atomic parameter edits and save/load/re-edit. It includes the supported/refused shapes, error handling and initial resource limits.
This API is bounded: convex XY line sketches, positive +Z extrusions, one X/Y through-slab cut and one admitted cardinal-edge chamfer. Native exactness and tool-coverage rules still apply. It does not establish arbitrary Boolean modeling, persistent topology naming or commercial CAD parity.
For Curve/Surface text programs or older saved feature documents, use the advanced language reference and historical compatibility links. Source package imports need a TypeScript-capable transformer; built ESM/declarations, registry publication and deployed editor support are separate stages. See the evidence boundary.
Overview · Model a part · Capabilities · Guides · API