CAD description notation
name = CAD … END constructs an immutable caddefinitionv2 description. name = CAD(parameters) … END defines a reusable, pure description function. CAD name(parameters) … END is the…
CAD description notation
name = CAD … END constructs an immutable cad_definition_v2 description.
name = CAD(parameters) … END defines a reusable, pure description function.
CAD name(parameters) … END is the alternative declaration spelling; source
formatting preserves the chosen header. Both forms use ordinary Rust-hosted
LIR and the existing CAD constructors.
Description construction does not create native solids or start a job. Select
geometry = CAD.EVALUATE(part_design, "composition") explicitly to admit the
first enclosure package through the existing native resident owner. Admission
proves bounded typed inputs, literal dispatch, finite collections, checked
rectangle placements and the generated CAD declarations. Unsupported operations
fail admission; this profile does not execute general solvers or repair calls.
The profile supports independent blind extrusions on signed-axis datums, with
exact line and endpoint-arc boundaries and generated identities. Native
measurements and STEP exports select a body such as floor; they remain bound
to the current source and input revision. Reference/attachment execution retains
its separate contract. The implementation ledger
records host workflow validation and performance evidence separately.
mounting_plate = CAD(instance_key, width, height, thickness)
KEY instance_key
UNITS mm
SKETCH outline ON XY
RECTANGLE boundary SIZE width BY height
CIRCLE left_hole CENTER (8mm, height / 2) RADIUS 2mm
CIRCLE right_hole CENTER (width - 8mm, height / 2) RADIUS 2mm
SLOT adjustment FROM (width / 2 - 4mm, height / 2)
TO (width / 2 + 4mm, height / 2) RADIUS 2mm
PROFILE region OUTER boundary HOLES left_hole, right_hole, adjustment
END
BODY part = EXTRUDE outline.region BY thickness
END
part_design = mounting_plate("controller", 48mm, 24mm, 4mm)
The part describes a 48 × 24 × 4 mm plate with two round holes and a capsule
slot. Its independent material-volume control is 4480 - 48*pi mm³, checked
against native realization of the generated description.
The reusable source is mounting-plate.gs.
Lengths require physical quantities, including coordinates and zeros. UNITS
selects the description's working length unit; it does not silently attach a
unit to bare numbers. Equivalent quantities normalize to that unit. Runtime
arguments with the wrong dimension, nonfinite values, nonpositive sizes, radii
or extrusion depths refuse with an error. Descriptions retain exact line and
endpoint-arc primitives rather than approximating circles with polygons.
KEY is an explicit instance string. Datum, sketch, profile and feature IDs use
the existing CAD.INSTANCE_ID generated-origin contract with declaration,
instance and local keys. Coordinate edits do not change those identities.
Named BODY entries are public result keys such as part; their names are
case-insensitive and canonicalize to lowercase. A declaration rename is an
identity change. Entity/profile/body references resolve statically within the
block, not by vector position.
Supported clauses are:
| Clause | Meaning |
|---|---|
DATUM raised PARENT XY ORIGIN (0mm, 0mm, 4mm) |
Translate from a preceding datum; the built-in datum is XY |
AXES (+X, +Y, +Z) on a datum |
Optional proper signed-axis frame; reflections and repeated axes refuse |
SKETCH outline ON raised … END |
Group planar entities and selected profiles on a datum |
RECTANGLE boundary SIZE 48mm BY 24mm AT (0mm, 0mm) |
Four named line edges; omitted origin is working-unit zero |
CIRCLE hole CENTER (8mm, 12mm) RADIUS 2mm |
Two exact semicircular endpoint arcs |
SLOT adjustment FROM (20mm, 12mm) TO (28mm, 12mm) RADIUS 2mm |
Two lines and two endpoint arcs; positive horizontal or vertical centerline |
PROFILE region OUTER boundary HOLES hole, adjustment |
Explicit outer and hole membership |
BODY part = EXTRUDE outline.region BY 4mm |
Independent body with positive extrusion depth |
Overlapping/touching holes, self-intersections and native capability limits remain geometric validation concerns. Description syntax alone does not certify a solid. Unsupported nested CAD blocks, cell targets, assignment decorators, arbitrary-angle slots and frames are not part of this grammar.
Declarations allow at most 64 formals, 32 datums, 32 sketches, 32 bodies,
256 entities/profiles per sketch and 32 holes per profile. Expansion has a
262,144-expression ceiling, with existing compiler and constructor limits still
applying. The header through the first KEY/UNITS clause fits within 16 KiB.
Local names are unqualified and at most 128 bytes; primitive names
allow 120 bytes so generated edge suffixes also fit. A sketch.profile key is
at most 128 bytes and the declaration name at most 124. The same checks
apply to source-free owning syntax; rendering cannot make a forged primitive
executable. Reusable descriptions support normal imports and named arguments.
The enclosure library supplies layout, place
and describe. layout requests a solver result under VALIDATE EXACT; the
current numerical backend can converge while leaving tiny violations, in which
case validation withholds usable entities. place constructs the fixed assembly's
authored left-to-right arrangement and checks it against the same constraints.
It normalizes input lengths before arithmetic, retains invalid candidates only
as diagnostics, and makes no solver or optimality claim. It never rounds a solver
result or relaxes exact validation. The teaching model uses place.
describe independently checks the supplied placement against the
current dimensions, maps the board and supply by declaration ID, and returns
three body descriptions with eight floor holes. The dimension record has exactly
width, depth, height, wall, floor, lid and board_gap, all length
quantities. The floor must fit below the lid; this check uses the description's
normalized millimetres. The library loads only on an explicit USE through the
existing shipped source resolver.
The teaching model exposes
width, board gap and floor thickness, then explicitly selects native composition.
With the initial 120 × 80 mm dimensions, the material volume is
60352 - 16*pi mm³. Changing width to 12.6cm preserves declaration identities
and increases material volume by 2592 mm³. A source edit to an INPUT length literal
normalizes compatible entered units into its authored unit: 12.6cm replaces
120mm with 126mm. Unitless or dimensionally incompatible replacements refuse.
A 12 mm board gap is infeasible at
120 mm width; widening to 126 mm makes that arrangement feasible.
Source-bound experiments use run.kind: "cad" and a source_cad_v1 target,
with named description, placement and native-result selectors, explicit physical
units for each numeric INPUT axis, and selected body IDs. Each retained case
includes placement/geometry status, native method and bounds, volume units,
and mass/material-cost assumptions. Infeasible geometry has no fabricated zero
measurement. Study execution uses captured source and inputs without changing
the live model. Explicit publication uses the existing Frame and artifact owners.
Case adoption uses the existing source edit transaction and requires the same
source revision, no live overrides, and a feasible retained case. Host workflow
validation and performance evidence remain tracked in the implementation ledger.
The four-case experiment specification
can be submitted with the existing createExperiment(modelId, spec) operation
after opening the teaching source with native CAD ownership. Read the completed
cases through getExperiment and the retained-output inspection operation;
publishExperimentEvidence explicitly retains the numeric Frame plus v2 CAD
source, specification and typed-result artifacts. The older request-owned
Sketch v1 study schema and its verification endpoint remain separate.