step-examples/12-5-units/U025.stp
Sources
- 03-occt-tests.md R054 (bug23567 — `stepfileunits` returned wrong primary unit)
Description
The reader API entry point that returns the file's length unit reports a unit different from the one the receiver actually applied to coordinates during transfer. Downstream tools that read the reported unit and apply scaling produce wrong geometry; coordinates end up scaled inconsistently with the unit label.
Reproducer recipe
STEP with multiple `length_unit` records or with a `LENGTH_UNIT_AND_GLOBAL_UNIT_ASSIGNED_CONTEXT` complex; the file-units query returns an unrelated nested unit.
Expected kernel behavior
Heal and accept: normalize the file-units query to walk the active context tree and return the unit actually applied to coordinates, not an arbitrary nested unit definition.
Notes
**See also**: N018. Synonyms: "STEP reader returns wrong primary unit", "stepfileunits returns wrong unit", "file-units API inconsistent with applied unit", "primary length unit mismatched", "reader API unit query wrong".
Expected validation
occt=empty/empty gmsh=empty ifc=schema_n/a
Byte assertions
count(b'LENGTH_UNIT()') >= 2count(b'LENGTH_UNIT') >= 2
Tier-3 assertions
shape_null == True
Cross-references
Live oracle output
No live oracle data — run _run_corpus to populate.
Fixture content
Show fixture bytes (with defect highlighting)
1ISO-10303-21; 2/* U025: Multiple LENGTH_UNIT() records cause reader API to report wrong primary unit */ 3/* Primary context uses mm; secondary context has an extra LENGTH_UNIT() for metres */ 4/* stepfileunits API returns the wrong (secondary) unit instead of mm */ 5HEADER; 6FILE_DESCRIPTION(('U025: Multi-context file with wrong primary length unit from API'),'2;1'); 7FILE_NAME('U025.stp','2026-06-20T00:00:00',(''),(''),'cad-research-suite','',''); 8FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }')); 9ENDSEC; 10DATA; 11/* Geometry: 50x50x25 mm part */ 12#1=CARTESIAN_POINT('origin',(0.,0.,0.)); 13#2=CARTESIAN_POINT('corner-x',(50.0,0.,0.)); 14#3=CARTESIAN_POINT('corner-y',(0.,50.0,0.)); 15#4=CARTESIAN_POINT('corner-z',(0.,0.,25.0)); 16#5=CARTESIAN_POINT('corner-xyz',(50.0,50.0,25.0)); 17/* Primary context: mm (the unit actually applied to coordinates) */ 18#10=(LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.)); 19#11=(NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.)); 20#12=(NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT()); 21#13=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(0.001),#10, 22 'distance_accuracy_value','maximum model space distance between geometric entities'); 23#14=(GEOMETRIC_REPRESENTATION_CONTEXT(3) GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#13)) 24 GLOBAL_UNIT_ASSIGNED_CONTEXT((#10,#11,#12)) REPRESENTATION_CONTEXT('3D Dimensions','3D')); 25/* DEFECT: secondary context with extra LENGTH_UNIT() in metres */ 26/* Reader API may pick this up and report metre as the primary unit */ 27#20=(LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT($,.METRE.)); 28#21=(NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.)); 29#22=(NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT()); 30#23=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.0E-6),#20, 31 'distance_accuracy_value','maximum model space distance between geometric entities'); 32/* Second GEOMETRIC_REPRESENTATION_CONTEXT with metre LENGTH_UNIT */ 33#24=(GEOMETRIC_REPRESENTATION_CONTEXT(3) GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#23)) 34 GLOBAL_UNIT_ASSIGNED_CONTEXT((#20,#21,#22)) REPRESENTATION_CONTEXT('CGR','3D')); 35/* Model entity is GEOMETRIC_CURVE_SET â OCC returns empty shape */ 36#30=GEOMETRIC_CURVE_SET('multi-context-wrong-api-unit',(#1,#2,#3,#4,#5)); 37ENDSEC; 38END-ISO-10303-21;