1.8 KiB
1.8 KiB
Porting a model into SolidCraft
For a model that already exists as code (build123d, CadQuery, OpenSCAD) or as STEP. The port is
done when the SolidCraft STEP export matches the source geometry for every parameter value you
check: compare_step.py reports xor at most 1e-3 mm3. Volume, area and centre of mass alone are
not enough: in one port, a hexagon left at dof 1 changed the volume by 2e-7 of the total and the
centre of mass by 3e-4 mm, while xor showed 56 mm3 in 96 pieces along the outer walls.
- Reference geometry in the design's frame. The SolidCraft origin is chosen by trap 1 of SKILL.md, so it often differs from the source. Translate the source model to the same frame and export it as STEP for each checked parameter value. Pick values that reach every branch of the layout logic.
- Deliberate differences. Logic that SolidCraft expressions cannot hold (conditionals, search) gets a closed formula. Check the formula against the source over a wide range of values in plain Python first, list where it differs, and apply the formula to the reference too (patch the source function), so the comparison stays like for like. Tell the user each difference.
- Export and compare. Add
parameters.changeandfile.export {path, bodies: [name]}per value to a script, run it, thenuv run --no-project --with build123d python $SKILL/scripts/compare_step.py actual.step reference.step. The pieces' boxes show where the shapes differ; a pair of pieces on the two halves of one face means that face is turned, usually by an under-constrained sketch. - Freeze the test. Measure the reference (volume, area, centre of mass, bounding box) and
put the numbers into the copy of
templates/test_design.pynext to the design. Ask the user before removing the source model; git history keeps it.