Skip to content

fix(ifc): the project's display units are read from its UnitsElem, one per spec, and units of specs the IFC does not assign are no longer reported as unmapped (RE-439) - #1796

Merged
DrunkOnJava merged 5 commits into
DrunkOnJava:mainfrom
puzzbobb:feat-project-units
Nov 12, 2026

Conversation

@puzzbobb

Copy link
Copy Markdown
Contributor

Summary

The export now reads the project's display units from the UnitsElem record, which holds a format map keyed by spec. Before, it counted autodesk.unit.* strings. The diagnostics now give the units the project's Project Units actually set: Core Interior is in feet and fractional inches, square and cubic feet, where it used to come out in metres, square inches and cubic inches. The warning "Unmapped Revit unit identifiers were preserved in diagnostics", which listed 130 to 146 electrical, HVAC and structural units on every multi-discipline template, is gone. The IFC does not change.

Motivation

Loading Core Interior in the web viewer shows "Unmapped Revit unit identifiers were preserved in diagnostics: autodesk.unit.unit:amperes-1.0.0, autodesk.unit.unit:britishThermalUnits-1.0.1, … · 1 more". These units are not unmapped. They are the display units of specs the IFC unit assignment has no slot for. The six units the count did keep were wrong on every file it read, metric ones included: rac_basic and RE1 Architecture came out in square inches and pounds. The count read every copy of the unit map the partition keeps, plus every other spec's unit, so the most frequent string won.

Changes

  • src/research/native_project_units.rs (new):
    • read decodes UnitsElem.m_units.m_formatOptionsMap through native_document: spec ForgeTypeId → FormatOptions.m_unitTypeId, symbol and accuracy.
    • It takes the record with m_famId unset. A family document kept inside a project has its own UnitsElem, named by m_famId. A family file has only one record, which names the family the file is, and that one is taken.
    • Revit 2015 to 2020's m_formatOptionsArr (an array with no spec names) is recognised and not read.
    • string_record_maps and resolve: where the walk gives no units, the map is taken from the string records (spec followed by unit, specs ascending), but only when every copy agrees.
  • src/reader.rs: RevitFile::project_units memoises the read. The export asks for it twice.
  • src/ifc/mod.rs:
    • recover_project_units takes length, area, volume, angle, structural mass and time from their specs (IFC_UNIT_SPECS). The frequency count is removed.
    • unknown_unit_identifiers and its warning now cover only those six.
    • New project_display_units lists every spec's unit.
    • A warning names a read failure only where the string maps disagree.
  • src/ifc/entities.rs (ForgeUnit):
    • Reads feetFractionalInches, fractionalInches (as inches; it was feet), metersCentimeters, degreesMinutes, usSurveyFeet, tonnes, usTonnesMass and milliseconds.
    • The kilogram's diagnostic label is now KILO GRAM (was GRAM) and the gram's is GRAM (was MILLI GRAM).
  • tests/walker_to_ifc_integration.rs: the 2024 sample family's length unit is asserted as millimeters, its own. The count's meters was wrong.
  • docs/export-diagnostics.md, docs/schemas/export-diagnostics.schema.json: the unit fields are redescribed, and project_display_units is added. It is optional, so the change is not breaking.
  • docs/status.md, docs/format-reconnaissance.md (addendum), reports/element-framing/RE-439-project-display-units.md, probes/examples/probe_re439_project_units.rs, changelog.d/fixed/project-display-units.md.

Testing

Unit tests are banned in this repository: do not add them. Show the change working end to end on real files instead.

  • tools/check-local.sh passes (fmt, clippy, rustdoc, build, real-file / CLI / contract checks)
    • tools/check-local.sh --corpus with both corpora set: all gates passed, integration 302 passed, 0 failed
    • cargo +1.87 check --profile ci --all-targets: no errors
  • Verified end to end on real Revit files: the command, the files (and their licence), and the measured result against Revit's own export are in the PR body, with the script or probe that reproduces it
    • cargo run --profile ci -p rvt-probes --example probe_re439_project_units -- FILE... on 131 files:
      • Revit 2021 to 2027: Core Interior (MIT, magnetar-io/revit-test-datasets), Autodesk's samples (research/autodesk-sample-projects.tsv), Snowdon Towers 2024 and 2025, and, local only, the RE1 and R2025 models, Golden Nugget, Autodesk's Japanese samples and Einhoven.
      • The phi-ag/rvt sample families of 2016 to 2026.
      • Revit 2015 to 2020 files.
    • 103 files read through the walk: 70 metric (millimetres), 2 metric (metres, Golden Nugget Architektur) and 31 imperial (feet and fractional inches).
    • 8 sample families of 2021 to 2027 read from their one string map.
    • 11 files of 2015 to 2020 hold the array and are not read; 9 more fail the walk and have no map.
    • The read takes at most 91 ms (Snowdon Towers Architectural).
    • Revit's own IFC export does not carry the display units; it declares SI units, as rvt-rs does. The witness here is the record itself, against what the old count gave (report section 8).
  • If this touches the IFC exporter: the witness verdicts replay (see CONTRIBUTING.md) or the changed observations are refreshed in this PR
    • The IFC does not change. I compared rvt-ifc --profile ci of main (7cbbe5b3, before the rebase onto e8a99d03) and of this branch on ten files: Core Interior, rac_basic 2020/2024/2027, Snowdon Towers Architectural 2024, Golden Nugget Architektur 2025, RE1 Architecture, the 2019 and 2024 sample families and the R2025 Beam.rfa. The IFCs are identical line for line apart from FILE_NAME/IFCOWNERHISTORY. The diagnostics differ only in the unit fields and in confidence.warning_count, which drops by one.
    • IFCUNITASSIGNMENT (a witnessed field) is written by the step writer from a fixed SI list, which this change does not touch.
  • If this is a performance change: reran tools/bench.sh and attached the before / after
    • N/A: not a performance change. The added read is one UnitsElem record, at most 91 ms, once per export.

Audit-honesty checklist

  • README / docs reflect the current state after this PR — no claims of features that are not actually shipped in this PR
  • A user-visible change has its entry as a fragment under changelog.d/<section>/ (see changelog.d/README.md), not in CHANGELOG.md
    • changelog.d/fixed/project-display-units.md; tools/release/changelog.py check passes.
  • If a limitation was resolved, the "Known limitations" / "What works today" section in the relevant docs is updated
    • docs/status.md, RE-439 entry.
  • If a new limitation was introduced, it is documented in the PR body and in-code
    • No new limitation. The existing one, Revit 2015 to 2020 units not read, is now stated in native_project_units and the report (section 4). Four metric pairs of saves fix position 0 as length and integer 2 as millimetres, but nothing else.
  • Commit messages describe WHAT changed and WHY, not "fix things" or "updates"
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • If this is a reverse-engineering finding: a reproducible probe under probes/examples/ and a dated addendum to docs/format-reconnaissance.md are included

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0 (see CONTRIBUTING.md)
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content (see CLEANROOM.md)
    • The class and field names come from the file's own schema (Formats/Latest). The values are bytes of the files.
  • Any new test fixtures use synthetic values (testuser, 111111, FY-20XX, etc.) and contain no real-world PII
    • No fixtures added.

Breaking changes

None. recovered_unit_identifiers and unknown_unit_identifiers keep their types, and project_display_units is a new optional field. ForgeUnit is #[non_exhaustive]; its new variants are additions.

Screenshots or output samples

Core Interior, decoded in the diagnostics:

main this PR
recovered_unit_identifiers meters, squareInches, cubicInches, degrees, poundsMass, seconds feetFractionalInches, squareFeet, cubicFeet, degrees, poundsMass, seconds
unknown_unit_identifiers 130 identifiers none
project_display_units absent 136 specs
unit warning "Unmapped Revit unit identifiers were preserved in diagnostics: autodesk.unit.unit:amperes-1.0.0, …" none

Related issues

Refs #403 (the unit assignment). No issue was filed; the warning was seen in the web viewer.

…e per spec, and units of specs the IFC does not assign are no longer reported as unmapped (RE-439)

The export took every autodesk.unit.* string of the partition and kept,
for each IFC unit type, the identifier seen most often. Those strings are
every copy of the project's unit map plus every other spec's unit, so the
count picked by frequency: Core Interior (feet and fractional inches) came
out in metres, square inches and cubic inches, the metric rac_basic and
RE1 Architecture in square inches and pounds, and the 130 to 146 units of
electrical, HVAC and structural specs were warned about as unmapped.

A document's Project Units are its UnitsElem record: from Revit 2021,
m_units.m_formatOptionsMap maps each spec's ForgeTypeId to a FormatOptions
whose m_unitTypeId is the display unit (133 to 150 specs on the corpus).
native_project_units::read decodes it through native_document; a family
document inside a project has its own UnitsElem named by m_famId and is
skipped, and a family file's one record is taken. Where the native walk
does not read the file (Autodesk's sample families), resolve takes the
map its string records spell out (spec followed by unit, ascending) when
every copy agrees. Revit 2015 to 2020 save an array without spec names,
which is recognised and not read.

The export takes length, area, volume, angle, structural mass and time
from their specs. recovered_unit_identifiers are those six,
unknown_unit_identifiers only those of the six with no IFC unit, and the
new project_display_units lists every spec's unit. ForgeUnit reads
feetFractionalInches, fractionalInches (inches, was feet),
metersCentimeters, degreesMinutes, usSurveyFeet, tonnes, usTonnesMass and
milliseconds, and labels kilograms KILO GRAM and grams GRAM.

The IFC is unchanged (values and unit assignment stay SI): ten exports,
including Core Interior, Snowdon Towers Architectural and Golden Nugget,
are identical to main's but for timestamps, and their diagnostics differ
in the unit fields and one fewer warning alone. The read is done once per
export and takes at most 91 ms. Probe: probe_re439_project_units on 131
files.
@DrunkOnJava

Copy link
Copy Markdown
Owner

Thank you for this: a report, a probe, a 131-file run and an IFC comparison on ten files make it easy to review. One thing blocks it, and one thing follows.

Take RE-440 for the report. RE-439 was taken before this opened: #1791 merged reports/element-framing/RE-439-mesh-path-kept-partner-ends.md (and #1795 holds RE-441, #1797 RE-443), which is the red PII guard (RE-439 is also added by #1791 ... renumber this report). The later claim is renumbered and the maintainer names the number, so: reports/element-framing/RE-440-project-display-units.md, the probe as probes/examples/probe_re440_project_units.rs, and every citation of the id (the rustdoc and comments in src/, the docs/format-reconnaissance.md addendum, docs/status.md, the changelog fragment, the PR title and body). tools/ci/api-doc-ids.py fails on an RE id cited without its report, so a missed one shows up in CI.

Then I run the measurement. The change is meant to leave the IFC alone, and the only way to say that for all of Measure's exports is an unfiltered run: after your renumber commit I run one against main (every ifc.sha256 of the 126 exports, the diagnostics census and the semantic check) and read the diff of native_project_units.rs, ifc/mod.rs and entities.rs. Nothing more is asked of you unless that finds something.

@DrunkOnJava

Copy link
Copy Markdown
Owner

A heads-up while the renumber is pending: #1800 landed on main (3312271) and changes what a decoded graph's fields are, from serde_json::Value to rvt::research::graph_value::Fv. identifier_i64 in native_json.rs already takes &Fv, so once main is merged into this branch native_project_units.rs will fail to compile where it passes root.fields on:

  • family_of(fields: &serde_json::Value) and forge(pairs: &serde_json::Value) take &crate::graph_value::Fv.
  • get, indexing, as_str, as_i64, pointer and is_* read as before; as_array is a slice, so .as_array() followed by .iter() is unchanged; the probe takes fields.to_json() where it prints JSON.

If you would rather not do that merge yourself, say so and I will push it with the fix to your branch (maintainer edits are on) after the renumber commit. The measurement I described above still runs after the renumber.

puzzbobb and others added 3 commits November 12, 2026 07:34
…e report takes RE-445

Merging main brought DrunkOnJava#1800, which makes a decoded graph's fields rvt::research::graph_value::Fv: forge reads its format map through it. RE-439 is DrunkOnJava#1791's report on main, so this one is RE-445 (report, probe and every citation of the units reading).
@DrunkOnJava

Copy link
Copy Markdown
Owner

I pushed two commits to your branch (maintainer edits are on), so it can go through CI without waiting on another round trip; please pull them before you push again.

tools/ci/api-doc-ids.py passes locally. The measurement itself is untouched; I will run the unfiltered Measure on the final head once CI is green.

@DrunkOnJava

Copy link
Copy Markdown
Owner

Fast and full CI are green on c016643b (it holds the two commits I pushed: the Fv read and the RE-445 renumber). This change moves the diagnostics of every export and says the IFC does not move, so I measure that before it lands. I register what I will read, then run one unfiltered Measure of this head against 09b18bd3 (the release commit it holds, so nothing from main after it enters the comparison), every scorer and the held-out pairs. Hold iff:

  1. The IFC does not move. Every export's ifc.sha256 equals the base's. Any difference is a defect of this change.
  2. The diagnostics move only where you say. Per export, the keys that differ from the base are decoded.recovered_unit_identifiers, the new decoded.project_display_units, confidence.warning_count and the warning list (the unmapped-units warning gone, 130 to 146 units on the multi-discipline templates); no other key differs.
  3. The units are the Project Units. On Core Interior and the Snowdon Towers models the six are feet and fractional inches, square and cubic feet, degrees, pounds and seconds; on rac_basic and RE1 Architecture millimetres, square and cubic metres and kilograms; no export reports a unit of the six that the old count gave and the record does not hold.
  4. Nothing else moves: the census, the quantity and property scorers and the witness lines are equal to the base's, and same-project gates pass.
  5. Not scored, said so: Revit's own export declares SI units and carries no display units, so what the units are is witnessed by the record (RE-445 section 8), not by a Revit export.

@DrunkOnJava

Copy link
Copy Markdown
Owner

The Measure read against the rows I registered: all five hold.

Run 43269120862: c016643b against the release commit 09b18bd3, unfiltered, every scorer, the held-out pairs.

  1. The IFC does not move. All 119 exports are byte for byte the base's, the held-out models included.

  2. The diagnostics move only where you say. 76 exports change, and in each one the keys that differ are these and no others:

    • decoded.recovered_unit_identifiers;
    • the new decoded.project_display_units;
    • decoded.unknown_unit_identifiers, which goes from 80 to 156 entries to none;
    • confidence.warning_count and the warning list, which each lose the one unmapped-units warning.

    My row described the emptied list by its count without naming the key, so I name it here. The 25 that do not change are the 24 samples of Revit 2015 to 2020 and the Vitoria 2018 model, which have no Forge unit records to read.

  3. The units are the Project Units.

    • Core Interior and Snowdon Towers Architectural and Structural: feetFractionalInches, squareFeet, cubicFeet, degrees, poundsMass and seconds.
    • RE1 Architecture and rac_basic 2024: millimeters, squareMeters, cubicMeters, degrees, kilograms and seconds.

    The old count gave meters on every one of the 76, with square and cubic inches on 32 of them and centimetres on the other 44. On all 76, every recovered unit is one of that file's own project display units.

  4. Nothing else moves. The census, the quantity and property scorers and the body scorers are equal to the base's. Core Interior's two witness observations differ only in their warning list, by the same unmapped-units warning, and no witness count changes. same-project gates pass (15 samples, plus the Areas on four saves and the 2021 save).

  5. Not scored, said so. Revit's own export declares SI units and carries no display units, so the record witnesses these values (RE-445), not a Revit export.

semver checks, full / CI passed and the PII guard are green on this head. Because two of its commits are mine (the Fv read and the RE-445 renumber), the approval comes from the other maintainer session.

@DrunkOnJava
DrunkOnJava merged commit 97397b9 into DrunkOnJava:main Nov 12, 2026
76 checks passed
@puzzbobb
puzzbobb deleted the feat-project-units branch November 12, 2026 20:23
DrunkOnJava added a commit that referenced this pull request Nov 12, 2026
… pass where the handle holds it (#1816) (#1821)

## Summary

`native_project_units::read` now takes the project's display units from
the parameter definitions pass the handle already holds, rather than
walking every partition for the `UnitsElem` again. Where no such pass is
held, it walks as before. Exports and diagnostics are meant to be
unchanged.

## Motivation

#1816. #1796 read the units with a pass of its own (91 ms or less on
Snowdon Towers Architectural), although a default export has already
made the definitions pass, which decodes every `UnitsElem`. #1237's rule
is to fold a read into a pass that already selects its records.

## Changes

- `src/research/native_document.rs`:
- `DefinitionPass.units` keeps each `UnitsElem`'s outcome
(`native_project_units::units_of`) in walk order, its error kept as its
`{:#}` text;
- `definition_key` is factored out of `definition_pass`, so the
exhaustive destructure stays in one place;
- `held_definition_units` peeks the pass the handle holds under an
options' key, without making one.
- `src/research/native_project_units.rs`:
  - `units_of` is the read's per-record body, factored out;
- `read` replays the held pass's outcomes (stopping at the first error,
as its own walk does) or walks;
- `read_counts` is a thread-local count of which way each read went, for
the probe.
- `probes/examples/probe_1816_units_from_definitions.rs`:
  - counts how the default export's reads of the units went;
- compares a read after a definitions pass with the read alone on a
fresh handle.
- `changelog.d/changed/1816-units-from-definitions.md`.

The read never makes the definitions pass itself. It costs 0.4 to 0.9 s,
more than the read, and the handle's one slot would lose another
reader's pass. `Registry::ingest_units` is untouched.

## Testing

Rows registered on #1816 before the run
([comment](#1816 (comment))):
1. Every export and every file Measure compares, the diagnostics
included, equal `main`'s.
2. The probe: the folded read equals the read's own walk on every model.
On every reference model and every 2024 to 2027 sample, the export's
read takes the held pass.
3. Time does not regress: no 2023 to 2027 file more than 3% slower, and
the median of the 28 samples at or below 1.01. This is not a claim of a
saving.

Measure
[43291861101](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43291861101)
at `3c9eb5c8` failed row 2. Every model's read walked, because the
storey read dropped the definitions pass before the units were read;
`bb1ad607` reads them first. The rows are judged on the rerun, Measure
[43298644195](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43298644195),
at this head (`6ec32fbb`) against `main` at `eaf22753`, the merge's
parent. It covered nordic, r2025, samples, racadv and holdout, with
`timing=true` and the probe:

1. **Holds.** 125 of 125 `ifc.sha256` and 101 of 101 `diagnostics.json`
equal `main`'s. The scorer diff holds only output the head alone writes:
probe output and `areas_across_saves*`.
2. **Holds in part.** The folded read equals the read's own walk on
every model (202 probe outputs, all `equal=true`, all exit 0). The
export's read took the held pass on every reference model and every 2024
to 2027 sample except `rst_basic` 2024 to 2027 (4 files, `held=0
walked=1`).
- On those 4 files no Level record is accepted: their 2 storeys fall
back to record-box elevations.
- So `apply_partition_level_storeys` returns before the storey read
makes the definitions pass, and the units read walks, as it did before
this change.
- The read never makes the pass itself (see Changes), so those 4 files
are unchanged rather than folded. As written, the row does not hold for
them.
3. **Holds.** Over the 28 samples of 2023 to 2027, the median time ratio
is 0.99, the slowest is 1.02 (2023 `rac_advanced`), and none is over
1.03. The peaks are 1.00 to 1.02, the 1.02 on the concrete office at
permit (1,018 to 1,042 MiB). This is not a claim of a saving.

- [ ] `tools/check-local.sh`: CI is the compiler here; the draft runs
fast CI.
- [x] End to end on real files: the run above.
- [x] IFC exporter output: meant to be unchanged (row 1).
- [x] Performance: Measure timing (row 3), not `tools/bench.sh`.

## Audit-honesty checklist

- [x] Docs unchanged: no capability moves.
- [x] Changelog fragment under `changelog.d/changed/`.
- [x] No new limitation.
- [x] Commit message says what and why.
- [x] No emojis, private paths or personal data.
- [x] Probe under `probes/examples/`.

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] No Autodesk proprietary source
- [x] No fixtures

## Breaking changes

None. `read_counts` is a new public research function, behind
`unstable-research`.

## Screenshots or output samples

The probe's counts are posted with the run.
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.

2 participants