Skip to content

fix(ifc): declare the SI units every value is written in (#403) - #411

Merged
DrunkOnJava merged 2 commits into
mainfrom
fix/ifc-si-unit-assignment
Sep 27, 2026
Merged

DrunkOnJava merged 2 commits into
mainfrom
fix/ifc-si-unit-assignment

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #403.

What changes

StepWriter::emit_unit_assignment always declares what the writer writes: METRE, SQUARE_METRE, CUBIC_METRE, RADIAN, KILO GRAM, SECOND. model.units (Revit's display units, IFC-40) no longer drives the IfcUnitAssignment; they remain in IfcModel.units and in the export diagnostics (recovered_unit_identifiers), where they describe the source model. The missing-units warning now says the IFC declares the SI units its values are written in.

Evidence (IfcOpenShell 0.8.5 as the reader)

unit scale 20 ft north wall extent second storey elevation
synthetic-project.ifc on main 0.001 6.1 mm x 0.2 mm x 3.0 mm 3 mm
this PR 1 6.096 m x 0.2032 m x 3.048 m 3.048 m

Real exports (Einhoven, Projeto1) now declare the six SI units; before, Einhoven declared SQUARE_INCH / CUBIC_INCH / DEGREE / POUND and Projeto1 CENTI SQUARE_METRE, over values the writer converts to SI. No value in those exports used those measures yet, so their geometry does not change; the fix matters from the first area, volume, angle or mass property on. Their display units (meters, squareInches … / squareCentimeters …) still appear in --diagnostics.

Checks

  • tools/check-local.sh: passed (fmt, clippy, rustdoc, 204 suites).
  • Fixtures regenerated with DUMP_IFC / DUMP_IFC_STRUCTURAL; tools/ci/ifc_schema_arity.py passes on both.
  • The three IFC-40 unit tests pinned the defect (a FOOT length unit over metre values); they are replaced by one test of the corrected rule. No new tests beyond that.

Residual

Which display unit rvt-rs reports is the most frequent autodesk.unit.* identifier per category in the partitions; on Einhoven (a Dutch model) that reports square inches for area, which looks wrong as a display unit. It no longer affects the IFC; it is diagnostics-only.

Breaking changes

Consumers that read the declared units get SI instead of the model's display units. Values are unchanged.

Legal and contribution hygiene

  • Apache-2.0; no Autodesk or ODA material.

Note

Medium Risk
Changes IFC unit metadata for all exports (breaking for consumers that trusted Revit's display units) while numeric geometry is unchanged; fixes 1000× scale errors in viewers that honor IfcUnitAssignment.

Overview
IFC IfcUnitAssignment now always matches the SI values the STEP writer emits (#403). Length is declared as metres (not millimetres on empty-unit models), and area, volume, angle, mass, and time are fixed to square metre, cubic metre, radian, kilogram, and second. Revit display units from model.units no longer drive STEP emission; they stay on the model and in export diagnostics (recovered_unit_identifiers).

The writer drops Forge-based unit mapping, IfcConversionBasedUnit chains, and the legacy millimetre default. emit_unit_assignment is a fixed six-IfcSIUnit table; the missing-units warning text is updated accordingly. Tests are consolidated into one case that asserts the same SI assignment whether units is empty or declares feet/inches/mm. Synthetic IFC fixtures are regenerated (metre length, mass/time units).

Reviewed by Cursor Bugbot for commit 1e735c813c93641ea79d8d6c4082234dacee3a9c. Configure here.

@cursor

cursor Bot commented Sep 27, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_b6556a90-f794-487e-8fcc-39b1994cac9d)

The writer writes lengths in metres, areas and volumes in square and cubic
metres, angles in radians and masses in kilograms, but the unit assignment
declared millimetres when a model carried no units, so IfcOpenShell read the
synthetic fixture's 20 ft wall as 6 mm long; and on real files it declared
Revit's display units (square inches, cubic inches, degrees, pounds on
Snowdon Towers). The assignment is now always metre, square metre, cubic
metre, radian, kilogram and second. Revit's display units stay in the
export diagnostics.
@DrunkOnJava
DrunkOnJava force-pushed the fix/ifc-si-unit-assignment branch from 1e735c8 to 3685061 Compare September 27, 2026 19:32
… unit set (#403)

The IFC no longer writes Revit's display units as conversion-based units, so its entity counts lose four IFCCONVERSIONBASEDUNIT, IFCDIMENSIONALEXPONENTS and IFCMEASUREWITHUNIT entries. Both Core Interior verdicts replay PASS with three matches.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) September 27, 2026 19:40
@DrunkOnJava
DrunkOnJava merged commit 2f31b3d into main Sep 27, 2026
21 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/ifc-si-unit-assignment branch September 27, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IFC unit assignment declares Revit's display units, and millimetres when none are recovered, while values are written in SI metres

1 participant