Repository navigation
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
Conversation
…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.
|
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 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 |
|
A heads-up while the renumber is pending: #1800 landed on
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. |
…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).
|
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.
|
|
Fast and full CI are green on
|
|
The Measure read against the rows I registered: all five hold. Run 43269120862:
|
… 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.
Summary
The export now reads the project's display units from the
UnitsElemrecord, which holds a format map keyed by spec. Before, it countedautodesk.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_basicand 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):readdecodesUnitsElem.m_units.m_formatOptionsMapthroughnative_document: specForgeTypeId→FormatOptions.m_unitTypeId, symbol and accuracy.m_famIdunset. A family document kept inside a project has its ownUnitsElem, named bym_famId. A family file has only one record, which names the family the file is, and that one is taken.m_formatOptionsArr(an array with no spec names) is recognised and not read.string_record_mapsandresolve: 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_unitsmemoises the read. The export asks for it twice.src/ifc/mod.rs:recover_project_unitstakes length, area, volume, angle, structural mass and time from their specs (IFC_UNIT_SPECS). The frequency count is removed.unknown_unit_identifiersand its warning now cover only those six.project_display_unitslists every spec's unit.src/ifc/entities.rs(ForgeUnit):feetFractionalInches,fractionalInches(as inches; it was feet),metersCentimeters,degreesMinutes,usSurveyFeet,tonnes,usTonnesMassandmilliseconds.KILO GRAM(wasGRAM) and the gram's isGRAM(wasMILLI GRAM).tests/walker_to_ifc_integration.rs: the 2024 sample family's length unit is asserted asmillimeters, its own. The count'smeterswas wrong.docs/export-diagnostics.md,docs/schemas/export-diagnostics.schema.json: the unit fields are redescribed, andproject_display_unitsis 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.shpasses (fmt, clippy, rustdoc, build, real-file / CLI / contract checks)tools/check-local.sh --corpuswith both corpora set: all gates passed, integration 302 passed, 0 failedcargo +1.87 check --profile ci --all-targets: no errorscargo run --profile ci -p rvt-probes --example probe_re439_project_units -- FILE...on 131 files: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.phi-ag/rvtsample families of 2016 to 2026.rvt-ifc --profile ciofmain(7cbbe5b3, before the rebase ontoe8a99d03) and of this branch on ten files: Core Interior,rac_basic2020/2024/2027, Snowdon Towers Architectural 2024, Golden Nugget Architektur 2025, RE1 Architecture, the 2019 and 2024 sample families and the R2025Beam.rfa. The IFCs are identical line for line apart fromFILE_NAME/IFCOWNERHISTORY. The diagnostics differ only in the unit fields and inconfidence.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.tools/bench.shand attached the before / afterUnitsElemrecord, at most 91 ms, once per export.Audit-honesty checklist
changelog.d/<section>/(seechangelog.d/README.md), not inCHANGELOG.mdchangelog.d/fixed/project-display-units.md;tools/release/changelog.py checkpasses.docs/status.md, RE-439 entry.native_project_unitsand the report (section 4). Four metric pairs of saves fix position 0 as length and integer 2 as millimetres, but nothing else.probes/examples/and a dated addendum todocs/format-reconnaissance.mdare includedLegal and contribution hygiene
CONTRIBUTING.md)CLEANROOM.md)Formats/Latest). The values are bytes of the files.testuser,111111,FY-20XX, etc.) and contain no real-world PIIBreaking changes
None.
recovered_unit_identifiersandunknown_unit_identifierskeep their types, andproject_display_unitsis a new optional field.ForgeUnitis#[non_exhaustive]; its new variants are additions.Screenshots or output samples
Core Interior,
decodedin the diagnostics:mainrecovered_unit_identifiersmeters,squareInches,cubicInches,degrees,poundsMass,secondsfeetFractionalInches,squareFeet,cubicFeet,degrees,poundsMass,secondsunknown_unit_identifiersproject_display_unitsRelated issues
Refs #403 (the unit assignment). No issue was filed; the warning was seen in the web viewer.