Diff Model Geometry
diff_geometryUse this when you need to know WHAT MATERIAL changed between two versions of a model, not just how much. The deeper sibling of diff_scripts: a volume delta alone is ambiguous (a boss that grew and a pocket that deepened report the same magnitude, and a part that only moved reports zero), so this tool answers it with geometry instead of pixels. Baseline is { base_file } or { base_code }; the revised side is either another script ({ file } or { code }) or the SAME script re-lowered with { params } overrides — a bag of declared param() name -> new value, which is the one-script form a parameter sweep actually asks for. Bodies pair by name and fall back to declaration-order positional pairing; anything left over is listed in unmatched and raises diff.body.unmatched. Per matched body it returns addedMm3 = volume(revised - base), removedMm3 = volume(base - revised), commonMm3 = volume of the overlap from boolean intersection, exact bbox with min/max/extent deltas, face / edge / hole count deltas (hole counts reuse the cylindrical-hole detector), maxDeviationMm (two-sided discrete Hausdorff distance between the two surfaces), and a verdict — identical | moved | resized | topology-changed, precedence topology-changed > resized > moved > identical. Branch on the verdict; cite the numbers. Each body also carries faces - WHICH faces changed: { added, removed, modified, unchangedCount } where each entry is { surfaceType (plane | cylinder | cone | sphere | torus | bspline | other), areaMm2, center, normal (planes), axis (cylinders/cones), radiusMm, ref (a stable @kc[...] face ref on the revised model when the face has a lineage name) } and a modified entry adds { before, after, offsetMm, change: 'moved' | 'resized' | 'reshaped', matchedBy: 'lineage' | 'geometry' }. Faces pair by lineage first (the feature and role that made them, so a translated box reports six moved faces, not six removed + six added), then by geometry (same surface type, parallel normal/axis, nearest centroid). Lists are deterministic and capped at 50 with a truncated flag and true totals (addedCount / removedCount / modifiedCount). summary.text says it in plain language, e.g. "Body '(root)' topology-changed: 1 face added (cylinder r=3 at (20, 20, 3)), 2 faces resized (...)". Optional { render: true } also writes an overlay PNG (added green, removed red, unchanged material as a translucent ghost; the scene is a re-runnable .kcad.ts over lossless BREP sidecars) through the render_preview pipeline and fails open (the numeric diff is still returned) when that pipeline is unavailable. Read-only — never touches the active session.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "diff_geometry"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Revised script — inline source. Mutually exclusive with params. | |
| file | No | Revised script — path to a .kcad.ts file. Mutually exclusive with params. Hosted: `code`, `project:<slug>` (head), or a Studio `/p/<slug>?version=N` link (pinned); no local files. | |
| params | No | Param-override mode: re-lower the BASELINE with these declared param() values changed (e.g. { plateThickness: 8 }). Mutually exclusive with file/code. A name the baseline does not declare fails with the declared-param list in the message. | |
| render | No | Also render an overlay PNG — added material green, removed material red — via the render_preview pipeline. Off by default; the numeric table is the agent-facing evidence. | |
| out_dir | No | Directory for the overlay PNG, its STL inputs, and the generated overlay script. Default: a temp dir. | |
| base_code | No | Baseline script — inline source. | |
| base_file | No | Baseline script — path to a .kcad.ts file. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||