Wr045 — Unit name in `LENGTH_UNIT` changed without rescaling coordinate values

§12.13 writer-pathology (sub-class: units / coordinate scale)

P1 — silent data loss

writer

Sources

Sender

FreeCAD STEP exporter when the unit drop-down is changed (mm → m, mm → in) but the writer treats the unit choice as metadata only.

Description

A user authors a 10 mm cube. They change the export-unit setting to "m" (or "in"); the writer flips the `LENGTH_UNIT` text in the `GEOMETRIC_REPRESENTATION_CONTEXT` but emits the same numeric values. Re-import produces a 10-metre or 10-inch cube. Distinct from Wr044 because the trigger is "user selected a different unit on the way out" rather than "the source kernel was already mm". Bug-reporter language: "labels change but numbers don't".

Reproducer recipe

a 10 mm cube; declare `LENGTH_UNIT` as SI metre (`SI_UNIT($,.METRE.)` — *not* `MILLI`) but emit corner coordinates `(10.0, 10.0, 10.0)`.

Expected kernel behavior

writer multiplies/divides coordinates whenever the declared unit differs from the canonical kernel unit; or refuses the unit change with a clear diagnostic.

Notes

Cousin of Wr044 (inch case) and Wr035 (scale-applied-twice). Synonyms: "metre unit but mm values", "unit field decorative", "STEP exporter doesn't convert when user changes units". Provenance tier: writer-side (Q5 reclassification 2026-07-01).

Expected validation

occt=empty/empty gmsh=empty ifc=schema_n/a

Provenance tier

writer-side — defect not fully embodied in fixture bytes.

Byte assertions

Tier-3 assertions

Cross-references

Wr044, Wr035

Live oracle output

No live oracle data — run _run_corpus to populate.

Fixture content

Show fixture bytes (with defect highlighting)
1ISO-10303-21;
2/* Wr045: unit name in LENGTH_UNIT changed without rescaling coordinate values */
3/* FreeCAD #20546: user changes export unit mm → m; writer updates the unit label */
4/* but does NOT divide coordinates by 1000 — values stay as-is (mm numbers) */
5/* A 10 mm cube is emitted with coordinates (10.0,10.0,10.0) under SI METRE */
6/* Receivers that honour the metre unit load a 10-metre cube instead */
7HEADER;
8FILE_DESCRIPTION(('Wr045: LENGTH_UNIT says metre but coordinates are in mm'),'2;1');
9FILE_NAME('Wr045.stp','2026-06-20T00:00:00',(''),(''),'cad-research-suite','','');
10FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }'));
11ENDSEC;
12DATA;
13/* DEFECT: SI_UNIT($,.METRE.) — no MILLI prefix — declares metre as the length unit */
14/* DEFECT: coordinates are 10.0 (millimetre values); correct metre values would be 0.01 */
15#1=CARTESIAN_POINT('origin',(0.,0.,0.));
16#2=CARTESIAN_POINT('corner-x',(10.0,0.,0.));
17#3=CARTESIAN_POINT('corner-y',(0.,10.0,0.));
18#4=CARTESIAN_POINT('corner-z',(0.,0.,10.0));
19#5=CARTESIAN_POINT('corner-xyz',(10.0,10.0,10.0));
20#6=DIRECTION('xdir',(1.,0.,0.));
21#7=DIRECTION('zdir',(0.,0.,1.));
22/* DEFECT: $=no prefix means base unit METRE; coordinates 10.0 are mm values not metres */
23#8=(LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT($,.METRE.));
24#9=GEOMETRIC_CURVE_SET('metre-unit-mm-values-shape',(#1,#2,#3,#4,#5));
25ENDSEC;
26END-ISO-10303-21;