Files
cdsl-cad/json_to_cdsl/README.md
T
2026-08-24 14:52:08 +08:00

50 lines
2.0 KiB
Markdown

# JSON to CDSL
This program converts SolidWorks export JSON into parameterized Learning IR
(`*.cdsl.json`).
Conversion responsibilities:
- normalize SolidWorks JSON into an intermediate representation;
- classify sketches into named parameterized profiles;
- reuse equivalent profiles through semantic references;
- derive deterministic geometry through the sketch solver;
- remove avoidable floating-point noise;
- report unsupported or non-self-sufficient shapes.
The converter must not hide missing geometry behind an external context file
when producing a training-ready CDSL artifact.
## Evidence v2 batch converter
`evidence_v2_to_cdsl.py` converts the newer
`solidworks.cad_evidence.v2` extraction format into semantic CDSL v1.1. It
does not modify the current rebuild engine: features without a runtime
implementation are emitted with `execution_status: "deferred"` instead.
```bash
PYTHONPATH=backend/engine python json_to_cdsl/evidence_v2_to_cdsl.py \
json_to_cdsl/input/evidence_v2 \
--truth-dir json_to_cdsl/input/evidence_v2/truth \
--out json_to_cdsl/output \
--workers 1
```
For every `*.solidworks_evidence_v2.json` input it writes:
- `<part_id>.cdsl.json`: self-contained semantic CDSL in millimetres;
- `<part_id>.diagnostic.json`: source blockers, deferred features, optional
`inferred_from_step` selectors, semantic validation, and STEP-versus-source
bounding-box/volume/area/topology metrics;
- `manifest.json`: batch-level counts and paths.
The optional STEP directory is used only to infer a host face when exactly one
candidate is compatible with a Hole Wizard's captured locations. Ambiguous
geometry stays in `unresolved`; the converter never invents a selector.
Source records are discovered recursively. Output remains flat and is named by
the normalized full source filename. Files that normalize to the same part ID
receive a deterministic relative-path hash suffix, so every input record maps
to a distinct output. When a matching STEP file exists, it is resolved through
the same relative subdirectory as its source record.