agentcad-cli 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentcad/__init__.py +3 -0
- agentcad/__main__.py +4 -0
- agentcad/_templates/__init__.py +0 -0
- agentcad/_templates/model/README.md +46 -0
- agentcad/_templates/model/design.json +43 -0
- agentcad/_templates/model/params.json +5 -0
- agentcad/_templates/model/part.py +33 -0
- agentcad/_templates/workspace/CLAUDE.md +420 -0
- agentcad/_templates/workspace/cadproject.json +7 -0
- agentcad/_templates/workspace/models/.gitkeep +0 -0
- agentcad/_templates/workspace/references/build123d-guide.md +671 -0
- agentcad/_templates/workspace/references/images/.gitkeep +0 -0
- agentcad/_templates/workspace/references/notes.md +3 -0
- agentcad/_templates/workspace/references/validation-strategy.md +378 -0
- agentcad/checks/__init__.py +130 -0
- agentcad/checks/mesh.py +131 -0
- agentcad/checks/relations.py +155 -0
- agentcad/checks/section.py +199 -0
- agentcad/cli.py +235 -0
- agentcad/contract.py +160 -0
- agentcad/geometry.py +417 -0
- agentcad/inspect.py +102 -0
- agentcad/jsonio.py +30 -0
- agentcad/measure.py +80 -0
- agentcad/payloads.py +24 -0
- agentcad/precheck.py +153 -0
- agentcad/probe.py +215 -0
- agentcad/render.py +166 -0
- agentcad/report.py +151 -0
- agentcad/review.py +399 -0
- agentcad/runner.py +182 -0
- agentcad/section.py +346 -0
- agentcad/stl.py +265 -0
- agentcad/templates.py +21 -0
- agentcad/validate.py +234 -0
- agentcad/workspace.py +173 -0
- agentcad_cli-0.1.1.dist-info/METADATA +145 -0
- agentcad_cli-0.1.1.dist-info/RECORD +41 -0
- agentcad_cli-0.1.1.dist-info/WHEEL +5 -0
- agentcad_cli-0.1.1.dist-info/entry_points.txt +2 -0
- agentcad_cli-0.1.1.dist-info/top_level.txt +1 -0
agentcad/__init__.py
ADDED
agentcad/__main__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# {name}
|
|
2
|
+
|
|
3
|
+
AgentCAD model folder.
|
|
4
|
+
|
|
5
|
+
## Files you edit
|
|
6
|
+
|
|
7
|
+
- `design.json` — design intent + validation checks (the design contract)
|
|
8
|
+
- `params.json` — tunable dimensions
|
|
9
|
+
- `part.py` — build123d geometry (must assign final shape to `result`)
|
|
10
|
+
|
|
11
|
+
## Recommended workflow
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
agentcad precheck {name} --json # 1. solve design.json statically
|
|
15
|
+
# write part.py once precheck is green
|
|
16
|
+
agentcad build {name} --json # 2. generate STEP/STL
|
|
17
|
+
agentcad measure {name} --json # 3. measure geometry stats
|
|
18
|
+
agentcad validate {name} --json # 4. run all checks (auto-renders SVGs)
|
|
19
|
+
agentcad review {name} --json # 5. pre-delivery checklist + relations matrix
|
|
20
|
+
agentcad deliver {name} --json # 6. write delivery manifest
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Common errors to design *against*
|
|
24
|
+
|
|
25
|
+
For every hole declared in `params.json`, also declare a `min_clearance` check
|
|
26
|
+
in `design.json` between the hole cylinder and each adjacent solid (walls,
|
|
27
|
+
plates, flanges, edges). This catches the classic "hole edge buried under a
|
|
28
|
+
wall" bug at design time, before any code is written.
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"id": "hole_X_clearance",
|
|
33
|
+
"type": "min_clearance",
|
|
34
|
+
"feature_a": {"type": "cylinder", "axis": "z",
|
|
35
|
+
"center": [hole_x, hole_y], "radius": hole_r,
|
|
36
|
+
"z_range": [z0, z1]},
|
|
37
|
+
"feature_b": {"type": "box",
|
|
38
|
+
"x_range": [...], "y_range": [...], "z_range": [...]},
|
|
39
|
+
"min_mm": 0.0
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
See `../references/validation-strategy.md` for a complete catalog of design
|
|
44
|
+
errors and the check types that catch them.
|
|
45
|
+
|
|
46
|
+
Generated artifacts go to `outputs/`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "design-spec.v1",
|
|
3
|
+
"model": "{name}",
|
|
4
|
+
"units": "mm",
|
|
5
|
+
"intent": "Default rectangular sample block.",
|
|
6
|
+
"features": [
|
|
7
|
+
{
|
|
8
|
+
"id": "base_block",
|
|
9
|
+
"intent": "Rectangular solid block with parameter-driven envelope.",
|
|
10
|
+
"checks": [
|
|
11
|
+
"bbox_size",
|
|
12
|
+
"watertight"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"checks": [
|
|
17
|
+
{
|
|
18
|
+
"id": "bbox_size",
|
|
19
|
+
"type": "bbox_size",
|
|
20
|
+
"expected": [
|
|
21
|
+
40.0,
|
|
22
|
+
30.0,
|
|
23
|
+
20.0
|
|
24
|
+
],
|
|
25
|
+
"tolerance": 0.2
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "watertight",
|
|
29
|
+
"type": "watertight",
|
|
30
|
+
"expected": true
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "step_artifact",
|
|
34
|
+
"type": "artifact_exists",
|
|
35
|
+
"path": "outputs/{name}.step"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "stl_artifact",
|
|
39
|
+
"type": "artifact_exists",
|
|
40
|
+
"path": "outputs/{name}.stl"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Default AgentCAD build123d model.
|
|
2
|
+
|
|
3
|
+
Tunable values live in params.json. The final geometry must be assigned to
|
|
4
|
+
global variable `result`.
|
|
5
|
+
"""
|
|
6
|
+
import json
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from build123d import *
|
|
10
|
+
|
|
11
|
+
PARAMS = json.loads((Path(__file__).with_name("params.json")).read_text(encoding="utf-8"))
|
|
12
|
+
|
|
13
|
+
length = float(PARAMS["length"])
|
|
14
|
+
width = float(PARAMS["width"])
|
|
15
|
+
height = float(PARAMS["height"])
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build():
|
|
19
|
+
with BuildPart() as bp:
|
|
20
|
+
add(Box(length, width, height))
|
|
21
|
+
return bp.part
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
result = build()
|
|
25
|
+
metadata = {
|
|
26
|
+
"schema": "agentcad.part.metadata.v1",
|
|
27
|
+
"units": "mm",
|
|
28
|
+
"anchors": {
|
|
29
|
+
"origin": [0, 0, 0],
|
|
30
|
+
"x_min": [-length / 2, 0, 0],
|
|
31
|
+
"x_max": [length / 2, 0, 0],
|
|
32
|
+
},
|
|
33
|
+
}
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
# AgentCAD Workspace
|
|
2
|
+
|
|
3
|
+
You are working in an AgentCAD workspace. Your job is to create and refine CAD
|
|
4
|
+
models using the `agentcad` CLI and build123d geometry library.
|
|
5
|
+
|
|
6
|
+
## Workflow (11 stages — do NOT skip stages)
|
|
7
|
+
|
|
8
|
+
Two new stages — **precheck** (before code) and **review** (before deliver) —
|
|
9
|
+
exist precisely to catch the failure modes listed below in
|
|
10
|
+
"Common Design Errors". Skipping them lets silent bugs pass.
|
|
11
|
+
|
|
12
|
+
1. **Understand**: read the user request, identify every feature.
|
|
13
|
+
2. **Contract**: write `models/<name>/design.json` with features + checks.
|
|
14
|
+
Declare shapes inline for `min_clearance` checks (see below).
|
|
15
|
+
3. **Params**: put tunable dimensions in `models/<name>/params.json`.
|
|
16
|
+
4. **Precheck**: `agentcad precheck <name> --json`. This solves the design contract
|
|
17
|
+
*statically* — without building. It catches interferences, schema errors,
|
|
18
|
+
and feature-coverage gaps before you write code. **Do not write part.py
|
|
19
|
+
while precheck fails.**
|
|
20
|
+
5. **Implement**: write `models/<name>/part.py` using build123d.
|
|
21
|
+
- Final object MUST be assigned to global variable `result`.
|
|
22
|
+
- Optional `metadata` dict gets written to metadata.json.
|
|
23
|
+
6. **Build**: `agentcad build <name>` (auto-cached unless `--force`).
|
|
24
|
+
7. **Measure**: `agentcad measure <name> --json` for STL geometry stats.
|
|
25
|
+
8. **Render**: `agentcad render <name> --views iso,back` (validate auto-renders).
|
|
26
|
+
9. **Validate**: `agentcad validate <name> --json`. Must be green.
|
|
27
|
+
10. **Review**: `agentcad review <name> --json`. Final pre-delivery checklist —
|
|
28
|
+
pairwise relations matrix, must-view SVGs, missing-check reminders.
|
|
29
|
+
**Do not run `agentcad deliver` while review fails.**
|
|
30
|
+
11. Run `agentcad deliver <name> --json` ONLY after review passes.
|
|
31
|
+
|
|
32
|
+
Do NOT manually export STEP/STL from part.py. The runner owns all exports.
|
|
33
|
+
|
|
34
|
+
## Rules
|
|
35
|
+
|
|
36
|
+
- Units are millimeters unless the user explicitly says otherwise.
|
|
37
|
+
- Coordinate convention: +X right, +Y back, +Z up.
|
|
38
|
+
- Do not write generated artifacts outside `models/<name>/outputs/`.
|
|
39
|
+
- Treat `design.json` as the design contract — source of truth for what the
|
|
40
|
+
model should be.
|
|
41
|
+
- Treat CLI JSON output as the source of truth for what the model actually is.
|
|
42
|
+
- Do not claim a model is complete until `agentcad validate` passes.
|
|
43
|
+
- Every requested feature MUST have at least one validation check.
|
|
44
|
+
- bbox + watertight alone are NOT sufficient — they pass even when features
|
|
45
|
+
are missing or hidden.
|
|
46
|
+
|
|
47
|
+
## Workspace Layout
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
models/<name>/
|
|
51
|
+
design.json Feature contract: features list + checks
|
|
52
|
+
params.json Tunable dimensions
|
|
53
|
+
part.py build123d geometry (assign to `result`)
|
|
54
|
+
metadata.json (auto-generated if part.py defines `metadata`)
|
|
55
|
+
outputs/
|
|
56
|
+
build.json Build report
|
|
57
|
+
geometry.json STL measurement report
|
|
58
|
+
validation.json Validation results
|
|
59
|
+
deliverable.json Delivery manifest
|
|
60
|
+
preview.iso.svg SVG preview
|
|
61
|
+
<name>.step STEP export
|
|
62
|
+
<name>.stl STL export
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Validation Check Types
|
|
66
|
+
|
|
67
|
+
| Check type | What it verifies |
|
|
68
|
+
|------------------------|-------------------------------------------------|
|
|
69
|
+
| bbox_size | Bounding box dimensions within tolerance |
|
|
70
|
+
| watertight | STL mesh has no boundary edges |
|
|
71
|
+
| min_triangles | Minimum triangle count (catches degenerate) |
|
|
72
|
+
| artifact_exists | File exists at path (relative to model dir) |
|
|
73
|
+
| metadata_equals | Value at path in metadata.json matches expected |
|
|
74
|
+
| outer_diameter_at_z | Outer diameter at a Z section plane (supports `center`) |
|
|
75
|
+
| inner_diameter_at_z | Inner diameter at a Z section plane (supports `center`) |
|
|
76
|
+
| diameter_decreases_along_z | Diameter monotonically decreases over Z range |
|
|
77
|
+
| volume_range | Volume within min/max bounds |
|
|
78
|
+
| section_bbox_at_z | Check an XY region at Z is "solid" or "void" |
|
|
79
|
+
| **min_clearance** | **Two declared shapes have ≥ N mm edge-to-edge gap** (precheck-able, no STL needed) |
|
|
80
|
+
| **hole_accessibility** | **Tool envelope of given radius can reach a hole at Z** (catches buried holes) |
|
|
81
|
+
| **min_wall_thickness** | **Min point-pair distance in a region** at Z (catches thin walls) |
|
|
82
|
+
| **feature_position** | **A point at (x,y,z) is in expected solid/void state** |
|
|
83
|
+
| feature_coverage | (auto) Every feature references a check |
|
|
84
|
+
|
|
85
|
+
## design.json Example
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"schema": "design-spec.v1",
|
|
90
|
+
"model": "bracket",
|
|
91
|
+
"units": "mm",
|
|
92
|
+
"intent": "L-bracket with two mounting holes",
|
|
93
|
+
"features": [
|
|
94
|
+
{
|
|
95
|
+
"id": "base_plate",
|
|
96
|
+
"intent": "Horizontal mounting plate",
|
|
97
|
+
"checks": ["base_bbox", "watertight"]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "mounting_holes",
|
|
101
|
+
"intent": "Two M4 clearance holes",
|
|
102
|
+
"checks": ["hole_count"]
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"checks": [
|
|
106
|
+
{"id": "base_bbox", "type": "bbox_size", "expected": [60, 40, 5], "tolerance": 0.3},
|
|
107
|
+
{"id": "watertight", "type": "watertight", "expected": true},
|
|
108
|
+
{"id": "hole_count", "type": "min_triangles", "expected": 100},
|
|
109
|
+
{"id": "step_file", "type": "artifact_exists", "path": "outputs/bracket.step"},
|
|
110
|
+
{"id": "stl_file", "type": "artifact_exists", "path": "outputs/bracket.stl"}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Common Design Errors (mandatory pre-design checklist)
|
|
116
|
+
|
|
117
|
+
Walk this list before writing every design.json. Each error lists a tool that
|
|
118
|
+
catches it automatically.
|
|
119
|
+
|
|
120
|
+
### A. Inter-feature spatial relations (most common, hardest to validate)
|
|
121
|
+
|
|
122
|
+
| Error | Symptom | How to prevent it |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| **Hole-wall interference** (hole edge buried under adjacent solid) | Top-down view shows hole half-covered by a wall, yet `inner_diameter_at_z` still passes | Add a `min_clearance` check: `feature_a` = hole cylinder, `feature_b` = adjacent box. Precheck reports the gap directly. |
|
|
125
|
+
| **Hole-edge break** | Hole sits too close to part edge, leaving a C-shaped opening after machining | Add a `min_clearance` check with `feature_b` set to the external bounding box's near edge; verify clearance > 0 |
|
|
126
|
+
| **Hole-to-hole punch-through** | Two holes spaced < their diameter apart, so the walls between them open up | Add a `min_clearance` check pairing both hole cylinders with `min_mm = 2 * wall_thickness` |
|
|
127
|
+
| **Rib obstructs assembly hole** | Bolt threads in but the wrench cannot turn | Add a `hole_accessibility` check with `clearance_radius` set to the wrench socket radius |
|
|
128
|
+
| **center-to-face used instead of edge-to-edge** (the classic human error) | Mental math says "hole_y=15, wall_y=16 ⇒ 1 mm gap", forgetting to subtract the 2.25 mm radius | **Always reason in edges: `hole_center ± hole_radius` must not enter the neighbouring solid's range.** |
|
|
129
|
+
|
|
130
|
+
### B. Manufacturability
|
|
131
|
+
|
|
132
|
+
| Error | Symptom | How to prevent it |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| **Wall too thin** | FDM print snaps; injection moulding short-shot | Add a `min_wall_thickness` check; the region must cross both wall faces; `min_mm ≥ 1.0` (FDM) or `≥ 0.8` (injection) |
|
|
135
|
+
| **Feature smaller than tool radius** | Sharp inner corners cannot be milled; ⌀1 mm holes cannot be drilled | Keep every radius in params.json ≥ 0.5 mm; add fillet radius ≥ 1 mm at sharp inner corners |
|
|
136
|
+
| **Undercuts / overhangs** | 3D printing requires support material | Inspect the iso / section SVGs in the review stage |
|
|
137
|
+
|
|
138
|
+
### C. Assembly and accessibility
|
|
139
|
+
|
|
140
|
+
| Error | Symptom | How to prevent it |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| **No room to drive the bolt** | Socket wrench will not seat | `hole_accessibility` check with `clearance_radius = (bolt_head_outer_diameter / 2) + 1` |
|
|
143
|
+
| **Blind hole shallower than the bolt** | Bolt bottoms out | `feature_position` at the bottom of the hole verifies solid; ensure `hole_depth ≥ bolt_length + 1` |
|
|
144
|
+
| **Tolerance stack-up** | Three features pass individually but the stack is out of spec | Roll the cumulative tolerance into the `min_mm` of a `min_clearance` check |
|
|
145
|
+
|
|
146
|
+
### D. Geometric integrity (build123d traps)
|
|
147
|
+
|
|
148
|
+
| Error | Symptom | How to prevent it |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| **`Box(...).moved(Location(...))` double-adds** | The shape appears once at the original location and once at the moved location | **Always use `with Locations((x, y, z)): Box(...)`; never `.moved()` inside a builder context.** |
|
|
151
|
+
| **`Locations + BuildSketch(Plane.XY)`** | The sketch stays at Z=0 and never moves to the intended Z | **BuildSketch must use `Plane(origin=(x, y, z))`; an outer `Locations` does not move the sketch plane.** |
|
|
152
|
+
| **Zero-volume subtraction** | `Mode.SUBTRACT` cuts nothing | When build fails after precheck passes, run `agentcad probe --scan` and confirm the `step_changes` match the intended features |
|
|
153
|
+
| **Tiny residual sliver** | A 0.001 mm Z-range error leaves a paper-thin shell behind | Add a +0.1 mm overshoot to subtraction radii / depths |
|
|
154
|
+
|
|
155
|
+
### E. Intent vs. implementation drift
|
|
156
|
+
|
|
157
|
+
| Error | Symptom | How to prevent it |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| **Feature in the wrong direction** (hole drilled the wrong way) | Validate passes but the function is broken | Use `feature_position` to assert a void point along the hole axis, then visually confirm via section SVG |
|
|
160
|
+
| **Param field silently ignored** | Editing params.json does not change the model | `print(PARAMS)` at the top of part.py; the effective values land in build.json |
|
|
161
|
+
| **bbox passes but interior is wrong** | Outer envelope is correct, hole positions and walls are not | bbox alone is insufficient — every feature needs a section / diameter / clearance check |
|
|
162
|
+
|
|
163
|
+
### Hard rules (violation ⇒ rewrite design.json)
|
|
164
|
+
|
|
165
|
+
1. **Every hole needs a `min_clearance` check** for each surrounding wall or adjacent solid.
|
|
166
|
+
2. **Reason edge-to-edge, never center-to-face**: clearance must be measured between feature edges, not between centerlines and faces.
|
|
167
|
+
3. **Every feature has at least one geometry check** (not just bbox/watertight). Resolve every weak-check warning before proceeding.
|
|
168
|
+
4. **Run `agentcad review` before every `agentcad deliver`** and visually inspect every entry in `must_view`.
|
|
169
|
+
|
|
170
|
+
## CAD TDD: mandatory workflow (checks first, geometry second)
|
|
171
|
+
|
|
172
|
+
**Every feature must have a check that can pass or fail before any geometry
|
|
173
|
+
is written. The order is not negotiable.**
|
|
174
|
+
|
|
175
|
+
### Four questions to answer per feature before coding
|
|
176
|
+
|
|
177
|
+
For every feature you plan to implement, fill in this table before writing
|
|
178
|
+
`part.py`:
|
|
179
|
+
|
|
180
|
+
| Feature | Shape | Center (cx, cy) | Z slice | Expected value | Check type |
|
|
181
|
+
|--------|------|-------------|-----------|------------|-----------|
|
|
182
|
+
| Outer shell | rectangle | — | — | [w, h, t] | bbox_size |
|
|
183
|
+
| Camera hole | W×H rectangle | (cx, cy) | wall_back/2 | min(W, H) | inner_diameter_at_z |
|
|
184
|
+
| Inner cavity | void | center | wall_back+2 | "void" | section_bbox_at_z |
|
|
185
|
+
| USB-C port | W×H rectangle | (0, y) | z_mid | min(W, H) | inner_diameter_at_z |
|
|
186
|
+
|
|
187
|
+
If you cannot fill in all four columns for a feature, you have not thought
|
|
188
|
+
it through — **do not start coding**.
|
|
189
|
+
|
|
190
|
+
### Step 1 — Red phase
|
|
191
|
+
|
|
192
|
+
After finishing `design.json`, write a minimal `part.py` that produces the
|
|
193
|
+
outer envelope only (no internal features) and run:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
agentcad validate <model> --json
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Expected outcome:
|
|
200
|
+
- `bbox_size` → ✅ passes (outer shell is correct)
|
|
201
|
+
- Every section check → ❌ fails (internal features not yet built)
|
|
202
|
+
|
|
203
|
+
**If a section check passes while its feature is missing, the check is
|
|
204
|
+
wrong — return to the table and redesign it.**
|
|
205
|
+
|
|
206
|
+
### Step 2 — Green phase (one feature at a time)
|
|
207
|
+
|
|
208
|
+
Implement one feature at a time and rerun `agentcad validate` immediately to
|
|
209
|
+
watch the matching check flip from ❌ to ✅. Do not batch up multiple
|
|
210
|
+
features before validating — incremental feedback is the whole point of TDD.
|
|
211
|
+
|
|
212
|
+
### Feature → Check cheat sheet
|
|
213
|
+
|
|
214
|
+
| Feature type | Check type | Z slice | Expected value | Tolerance |
|
|
215
|
+
|---------|-----------|-----------|--------------|-----------|
|
|
216
|
+
| Circular hole ⌀D | inner_diameter_at_z | mid-Z of hole | D | 0.3 |
|
|
217
|
+
| Rectangular hole W×H | inner_diameter_at_z | mid-Z of hole | min(W, H) | 3–5 |
|
|
218
|
+
| Rectangular void region | section_bbox_at_z expected="void" | mid-Z of feature | — | — |
|
|
219
|
+
| Solid face (back panel, boss) | section_bbox_at_z expected="solid" | mid-Z of face | — | — |
|
|
220
|
+
| Outer envelope | bbox_size | — | [total_w, d, h] | 0.5 |
|
|
221
|
+
| Taper / lead-in | diameter_decreases_along_z | z_range | — | — |
|
|
222
|
+
| **Any hole vs. adjacent solid** | **min_clearance** | — | feature_a / feature_b shape descriptors | min_mm=0 |
|
|
223
|
+
| **Bolt assembly hole** | **hole_accessibility** | working plane Z of the hole | hole_radius, clearance_radius | — |
|
|
224
|
+
| **Thin wall / rib** | **min_wall_thickness** | section Z, region restricted to the wall cross-section | min_mm=1.0 | 0.1 |
|
|
225
|
+
| **Direction / position marker** | **feature_position** | point=[x, y, z] | expected="solid"\|"void" | tol=0.5 |
|
|
226
|
+
|
|
227
|
+
**Z slice formula:** if a feature occupies `[z_bottom, z_top]` along Z, slice
|
|
228
|
+
at `z = (z_bottom + z_top) / 2`.
|
|
229
|
+
|
|
230
|
+
**When you do not know the expected value:** run `agentcad build`, then
|
|
231
|
+
`agentcad probe <model> --z <z> --json`. The `suggested_checks` field is ready to
|
|
232
|
+
paste straight into `design.json`.
|
|
233
|
+
|
|
234
|
+
**When you do not know which Z to probe:** run `agentcad probe <model> --scan --json`
|
|
235
|
+
to surface step changes (cavity start, wall transitions, etc.) automatically.
|
|
236
|
+
|
|
237
|
+
## design.json Schema Rules
|
|
238
|
+
|
|
239
|
+
`agentcad validate` checks the schema before running any geometry checks. Violations
|
|
240
|
+
cause the entire validation to fail with a `design_schema` error.
|
|
241
|
+
|
|
242
|
+
- **Every check must have a unique `id` field** — even simple checks like `artifact_exists`
|
|
243
|
+
- **`type` must be one of the supported check types** (see table above)
|
|
244
|
+
- **Feature `checks` arrays reference check ids** — typos will cause `feature_coverage` to fail
|
|
245
|
+
- **No duplicate check ids** — each `id` must appear exactly once in `checks`
|
|
246
|
+
|
|
247
|
+
## Shape Descriptors (used by min_clearance and other relational checks)
|
|
248
|
+
|
|
249
|
+
Relational checks (`min_clearance`, etc.) consume a unified shape descriptor.
|
|
250
|
+
Three shapes are supported, all axis-aligned:
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
// Cylinder along Z (most common — describes a hole through a plate)
|
|
254
|
+
{"type": "cylinder", "axis": "z",
|
|
255
|
+
"center": [-15.0, 15.0], "radius": 2.25,
|
|
256
|
+
"z_range": [0.0, 4.0]}
|
|
257
|
+
|
|
258
|
+
// Cylinder along Y (describes a transverse hole through an upright wall)
|
|
259
|
+
{"type": "cylinder", "axis": "y",
|
|
260
|
+
"center": [0.0, 20.0], // (cx, cz) for axis=y
|
|
261
|
+
"radius": 2.25,
|
|
262
|
+
"y_range": [16.0, 20.0]}
|
|
263
|
+
|
|
264
|
+
// Axis-aligned box (describes walls, plates, bosses)
|
|
265
|
+
{"type": "box",
|
|
266
|
+
"x_range": [-25.0, 25.0],
|
|
267
|
+
"y_range": [16.0, 20.0],
|
|
268
|
+
"z_range": [0.0, 30.0]}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Full `min_clearance` check example:
|
|
272
|
+
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"id": "left_hole_wall_clearance",
|
|
276
|
+
"type": "min_clearance",
|
|
277
|
+
"feature_a": {"type": "cylinder", "axis": "z",
|
|
278
|
+
"center": [-15.0, 15.0], "radius": 2.25,
|
|
279
|
+
"z_range": [0.0, 4.0]},
|
|
280
|
+
"feature_b": {"type": "box",
|
|
281
|
+
"x_range": [-25.0, 25.0],
|
|
282
|
+
"y_range": [16.0, 20.0],
|
|
283
|
+
"z_range": [0.0, 30.0]},
|
|
284
|
+
"min_mm": 0.0
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
The reported `actual_mm` is the **edge-to-edge distance**: negative means
|
|
289
|
+
interference, zero means touching, positive means clearance.
|
|
290
|
+
|
|
291
|
+
`agentcad precheck` evaluates every `min_clearance` check **before the build
|
|
292
|
+
runs**, so the classic "hole edge buried under a wall" bug is caught the
|
|
293
|
+
moment design.json is finalised — long before any geometry is generated.
|
|
294
|
+
|
|
295
|
+
## Validation Strategy
|
|
296
|
+
|
|
297
|
+
- For axisymmetric features (ducts, sockets, tapers): use `outer_diameter_at_z`
|
|
298
|
+
and `inner_diameter_at_z` at specific Z heights.
|
|
299
|
+
- For tapers and chamfers: use `diameter_decreases_along_z` with samples at
|
|
300
|
+
multiple Z values.
|
|
301
|
+
- For off-axis holes and rectangular cutouts: use `inner_diameter_at_z` with
|
|
302
|
+
`center` set to the hole/cutout centroid. The inner diameter approximates
|
|
303
|
+
the shortest transverse dimension (e.g., ~`min(W, H)` for a W×H rectangle).
|
|
304
|
+
- For solid/void verification of specific rectangular zones: use `section_bbox_at_z`
|
|
305
|
+
with `region: [[x_min,y_min],[x_max,y_max]]` and `expected: "solid"` or `"void"`.
|
|
306
|
+
- Tolerance: 0.1-0.2 mm for tight fits, 0.3-0.5 mm for general use, 0.5-1.0 mm
|
|
307
|
+
for non-critical parts. Section check uncertainty is ~0.1 mm.
|
|
308
|
+
- ⚠️ `watertight` does NOT confirm a cutout exists — a solid back panel and one
|
|
309
|
+
with a camera hole are both watertight. Always add a section check for cutouts.
|
|
310
|
+
- If `validate` output includes a `warnings` array, it means some features have
|
|
311
|
+
only trivial checks (bbox/watertight). Add a section/diameter/bbox check for
|
|
312
|
+
those features. Warnings do not fail validation but should be resolved.
|
|
313
|
+
Use `agentcad probe` to discover the correct `expected` values.
|
|
314
|
+
|
|
315
|
+
## Critical build123d Warning
|
|
316
|
+
|
|
317
|
+
**`Locations(x, y, z) + BuildSketch(Plane.XY) + extrude` does NOT place the
|
|
318
|
+
sketch at Z=z.** The sketch always stays on its own plane (Z=0 for Plane.XY),
|
|
319
|
+
regardless of any enclosing `Locations` context.
|
|
320
|
+
|
|
321
|
+
```python
|
|
322
|
+
# WRONG — sketch stays at Z=0, inner cavity obliterates back panel
|
|
323
|
+
with Locations((0, 0, wall_back)):
|
|
324
|
+
with BuildSketch(Plane.XY):
|
|
325
|
+
RectangleRounded(w, h, r)
|
|
326
|
+
extrude(amount=depth, mode=Mode.SUBTRACT)
|
|
327
|
+
|
|
328
|
+
# CORRECT — explicit origin positions the plane
|
|
329
|
+
with BuildSketch(Plane(origin=(0, 0, wall_back))):
|
|
330
|
+
RectangleRounded(w, h, r)
|
|
331
|
+
extrude(amount=depth, mode=Mode.SUBTRACT)
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Use `Locations` only with 3D primitives (Box, Cylinder, Cone). Use explicit
|
|
335
|
+
`Plane(origin=(x, y, z))` for BuildSketch positioning.
|
|
336
|
+
|
|
337
|
+
## CLI Quick Reference
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
agentcad new <model> # Create model (auto-inits workspace)
|
|
341
|
+
agentcad precheck <model> --json # Static design solve (run BEFORE writing part.py)
|
|
342
|
+
agentcad build <model> --json # Build and export STEP/STL (cached if unchanged)
|
|
343
|
+
agentcad build <model> --force --json # Force rebuild even when source is unchanged
|
|
344
|
+
agentcad measure <model> --json # Measure STL geometry
|
|
345
|
+
agentcad render <model> --json # Generate SVG preview (iso)
|
|
346
|
+
agentcad render <model> --views iso,back --json # Render multiple views at once
|
|
347
|
+
agentcad validate <model> --json # Run full validation (auto-renders iso+back)
|
|
348
|
+
agentcad review <model> --json # Pre-delivery checklist + relations matrix
|
|
349
|
+
agentcad deliver <model> --json # Write delivery manifest (only after review passes)
|
|
350
|
+
agentcad probe <model> --z <z> --json # Probe Z cross-section (XY plane)
|
|
351
|
+
agentcad probe <model> --z <z> "--center=cx,cy" --json # Probe Z at off-axis center
|
|
352
|
+
agentcad probe <model> --z <z> --region x0,y0,x1,y1 # Check solid/void in region
|
|
353
|
+
agentcad probe <model> --x <x> --json # Probe X cross-section (YZ plane)
|
|
354
|
+
agentcad probe <model> --y <y> --json # Probe Y cross-section (XZ plane)
|
|
355
|
+
agentcad probe <model> --scan --json # Auto Z-axis profile scan
|
|
356
|
+
agentcad probe <model> --scan --axis x --json # X-axis scan
|
|
357
|
+
agentcad probe <model> --scan --axis y --json # Y-axis scan
|
|
358
|
+
agentcad render <model> --section-z <z> --json # Section SVG at Z height
|
|
359
|
+
agentcad render <model> --section-x <x> --json # Section SVG at X position (YZ)
|
|
360
|
+
agentcad render <model> --section-y <y> --json # Section SVG at Y position (XZ)
|
|
361
|
+
agentcad inspect <model> --json # Three-axis scan + section SVGs + suggested probes
|
|
362
|
+
agentcad report <model> # Generate Markdown validation report
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
All commands accept `--project <dir>` (defaults to current directory).
|
|
366
|
+
All commands accept `--json` for machine-readable output.
|
|
367
|
+
|
|
368
|
+
### agentcad probe — Discover expected values before writing design.json
|
|
369
|
+
|
|
370
|
+
Run `agentcad probe` AFTER `agentcad build` and BEFORE filling in `expected` values in
|
|
371
|
+
design.json. The output includes `suggested_checks` — ready-to-paste JSON
|
|
372
|
+
snippets with actual measured values:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Find inner diameter of a camera cutout centred at (-10.3, 53.3) at z=0.75
|
|
376
|
+
agentcad probe my_case "--center=-10.3,53.3" --z 0.75 --json
|
|
377
|
+
# → suggested_checks.inner_diameter_at_z.expected = 44.49 (actual measured value)
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
For multiple Z heights in one call (e.g., to profile a taper):
|
|
381
|
+
```bash
|
|
382
|
+
agentcad probe my_part --z 2.0,5.0,8.0 --json
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Key Resources
|
|
386
|
+
|
|
387
|
+
Always-on reference docs in `references/` (read them as needed):
|
|
388
|
+
- `references/build123d-guide.md` — build123d API reference, patterns, common pitfalls
|
|
389
|
+
- `references/validation-strategy.md` — check types, section checks, tolerance, troubleshooting
|
|
390
|
+
|
|
391
|
+
`references/` is the home for project documentation that should be readable
|
|
392
|
+
by both humans and agents throughout the modeling loop.
|
|
393
|
+
|
|
394
|
+
## Querying build123d Documentation
|
|
395
|
+
|
|
396
|
+
When you need API details beyond the reference docs (e.g., how to select
|
|
397
|
+
edges for fillet, what parameters CounterBoreHole accepts, how Location
|
|
398
|
+
arithmetic works), query the build123d documentation directly:
|
|
399
|
+
|
|
400
|
+
```
|
|
401
|
+
WebFetch https://build123d.readthedocs.io/en/latest/<page>.html
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Key documentation pages:
|
|
405
|
+
|
|
406
|
+
- **Objects reference**: `objects` — Box, Cylinder, Cone, Sphere, Torus, Wedge
|
|
407
|
+
- **Operations**: `operations` — fillet, chamfer, hole, split, mirror, offset
|
|
408
|
+
- **Topology selection**: `topology_selection` — filter_by, sort_by, group_by
|
|
409
|
+
- **Selectors tutorial**: `tutorial_selectors` — edge/face selection patterns
|
|
410
|
+
- **BuildPart**: `build_part` — BuildPart context manager details
|
|
411
|
+
- **BuildSketch**: `build_sketch` — 2D sketch construction
|
|
412
|
+
- **Moving objects**: `moving_objects` — Location, rotation, alignment
|
|
413
|
+
- **Key concepts**: `key_concepts_builder` — Align, Mode, Select enums
|
|
414
|
+
- **Cheat sheet**: `cheat_sheet` — quick syntax reference
|
|
415
|
+
- **Examples**: `general_examples` — real-world model examples
|
|
416
|
+
|
|
417
|
+
All URLs follow the pattern:
|
|
418
|
+
`https://build123d.readthedocs.io/en/latest/<page>.html`
|
|
419
|
+
|
|
420
|
+
When stuck on a build123d API question, fetch the relevant page before guessing.
|
|
File without changes
|