Repository navigation
fix(elem_table): detect the record size by the ElementId, the second id - #737
Conversation
|
A follow-up I found while running the corpus targets with the Snowdon samples in The 84 ids without a record are exactly the
So they look like ids that belong to no element. I've left both alone in this PR. Two ways to close it:
The first changes what every caller of |
detect_layout picks the record size (28 or 40 bytes) at which the stated records fit from 0x06 with ids rising over the whole table. Since DrunkOnJava#559 it tested the record's first id. On Autodesk's Snowdon Towers samples that id differs from the second on 27 (Structural) and 84 (Architectural) records, and it falls back below its predecessor 2 and 3 times. Neither size passed, so the table was read in the 12-byte fallback layout, no element record found its ElementId (RE-30), and rvt-ifc exported 0 of Structural's 1,282 elements and 1 of Architectural's 6,056. The second id (+4 on 28 bytes, +20 on 40) is the ElementId that partition records, owners and Revit's own export carry (RE-41). It rises over every table measured: Snowdon Structural, Architectural and Plumbing, Core Interior, Einhoven, Autodesk's rac_basic 2019, 2022 and 2024, and the 2016 to 2026 families. On Snowdon every owner is one of the second ids, while 13 and 42 owners are none of the first ids. tests/elem_table_frame.rs checks rising ElementIds and owners on id_secondary (equal to id_primary on every file it read before), and reads the Snowdon samples when they are in RVT_PROJECT_CORPUS_DIR. Fixes DrunkOnJava#736. Co-Authored-By: Claude Opus 5.5 <[email protected]>
409cc4c to
0bd7ac7
Compare
|
Thank you for the bisect and the fix, and sorry for the wait. CI never ran on this PR because GitHub holds a first-time contributor's workflow runs until a maintainer approves them, and nobody was watching the queue for two weeks. The runs are approved now, and runs from established accounts no longer wait for approval. One change on your branch: The fix itself reads right to me: the rise test now reads the id that |
|
Opened #760 for the 84 first ids on Snowdon Architectural, with your measurements and both options. |
…ng it (#744) ## Summary Each `IfcSpace` is now an aggregated part of its storey (or of the `IfcBuilding` where no storey join reached it) through `IfcRelAggregates`, instead of an element of the storey's `IfcRelContainedInSpatialStructure`. Fixes #743. ## Motivation A space is a spatial element. Written as a contained element, it had no parent in the spatial tree: buildingSMART validation rules SPS002 and SPS007 flag it, and IfcOpenShell-based readers found no storey for the room or for the furniture B63 contains in it. ## Changes - `src/ifc/step_writer.rs`: spaces go to their own per-storey list (and an unplaced list for the building) instead of the containment lists; one `IFCRELAGGREGATES` per storey with spaces (GlobalId from `["aggregates", <storey gid>]`) and one for the building (`["aggregates", "building", "spaces"]`). B63's containment of elements in spaces is unchanged. Both parents are allowed by the spatial composition table (`IfcSpace` under `IfcBuildingStorey` or `IfcBuilding`). - `tests/space_containment.rs`: `spaces_are_aggregated_into_their_storey`, end to end on `2024_Core_Interior.rvt` and `RE1-Architecture.rvt` (corpus-gated, like the file's existing test). ## Testing - [x] `cargo fmt --check`, `cargo clippy --all-targets --locked -- -D warnings`: clean. - [x] `cargo test --release --test integration -- space_containment:: project_count_fixtures:: witness` with `RVT_PROJECT_CORPUS_DIR` = magnetar `fd755e18` + the RE1 files (hashes as in CI): 11 passed. The new test fails on `120e2f9` (Core Interior 116 of 116 spaces not aggregated, RE1-Architecture 11 of 11) and passes with the change (0 and 0). - [x] End to end on Snowdon Towers Sample Architectural (Autodesk sample, measured locally, not committed), with #737 merged so the file reads, against a Revit 2024 IFC4 RV export of the same file: all 54 spaces have a storey as parent (IfcOpenShell 0.9.0 `get_aggregate`); elements on Revit's storey 5,581 of 5,945, as with v0.4.0 (main + #737 alone: 4,813). - [x] Witness: the source witness's `entity_counts` counts `IFCRELAGGREGATES`, which goes from 3 to 13 on Core Interior (one per storey with rooms), so both committed rvt-rs observations are refreshed from this PR's CI artifact. Nothing else in them moves, both bridge witnesses replay, and no verdict changes. - [x] `tools/check-local.sh --corpus` (rustc 1.99.0, Debian bookworm): fmt, clippy, rustdoc and the workspace build clean; `verify-real-files.sh` 232 passed, 0 failed, both by default and against the corpora (phi-ag `d2eb1f3`, magnetar `fd755e18` + RE1). - N/A: performance.
…from the element association record (RE-172) (#751) Writes Revit's level parameters in a `Constraints` property set, read from the per-element association record (`d3 02 01 00 00 00 | ElementId | 0 | LevelId | 0 | ff x6`, LevelId at ElementId + 8). Closes #750. Names follow Revit's export per class: walls and curtain walls `Base Constraint` and `Top Constraint` (`Up to level: <name>`), columns `Base Level` and `Level`, railings, roofs and stairs `Base Level`, duct and pipe segments `Reference Level`, everything else `Level`. Values are `IfcLabel`, as in Revit's export. Fail closed: a value is written only when the id is a Level recovered by `partition_level_records`, and only for Revit 2024. Where the association record holds `0xffffffff` (beams, stairs, braces, some MEP terminals, lights and proxies), RE-174 below reads the level from elsewhere. `Top Constraint` is written only where its group is located inside the record and holds a recovered Level id, so coverage is partial. Additive: storey containment, `LevelElementId` and the level binding of RE-27, RE-59, RE-60 and RE-68 are untouched. Element counts and storey containment are identical to main (`120e2f9`) on all seven files measured. Measured against Revit's IFC4 export, by `Tag` (equal / elements where Revit has the property): | file | Level | Base Level | Base Constraint | Top Constraint | Reference Level | |---|---:|---:|---:|---:|---:| | racadvanced | 5214 / 5214 | 190 / 190 | 180 / 180 | 177 / 177 | | | Technicalschool | 5214 / 5214 | 190 / 190 | 180 / 180 | 177 / 177 | | | rmeadvanced | 4151 / 4151 | 141 / 141 | 166 / 166 | 165 / 165 | 1216 / 1216 | | rmebasic | 4196 / 4196 | 141 / 141 | 166 / 166 | 165 / 165 | 1215 / 1215 | | racbasic | 359 / 359 | 4 / 4 | 56 / 56 | 48 / 48 | | | rstadvanced | 502 / 502 | 203 / 203 | 6 / 6 | 6 / 6 | | | rstbasic | 67 / 67 | 30 / 30 | 9 / 9 | 9 / 9 | | Where rvt-rs writes a property Revit does not (racadvanced 1 `Base Level`, Technicalschool 6), it is counted outside the table. Not covered: stairs that rvt-rs does not decode as class `Stair`, `Top Constraint` on walls whose second group is not located, Revit 2023 and 2025, and DACH and Snowdon (no elements exported on main). Verification: `tests/level_parameters.rs` compares every written value with Revit's export (set `RVT_REVIT2024_SAMPLES_DIR` to a folder holding `racadvancedsampleproject.rvt` and its Revit IFC; it skips otherwise). The public corpus convention (`RVT_PROJECT_CORPUS_DIR`) has no Revit 2024 sample, hence the separate variable. `cargo fmt --check`, `cargo clippy --all-targets --all-features -- -D warnings` and `cargo doc` with `-D warnings` pass. `ifc_synthetic_project::synthetic_project_emits_valid_ifc4` fails on main too (expects 2 property sets, finds 12) and is not touched. Second test, on a CC BY-SA 4.0 file (`tests/level_parameters.rs`, `RVT_NORDIC_LCA_DIR`): BIM4LCA / Nordic LCA `ARK_NordicLCA_Housing_Terrain-Concrete_BuildingPermit.rvt` (Revit 2024, 17.6 MB; VTT, Granlund, Gravicon, Insinööritoimisto Kallinen; <https://cris.vtt.fi/en/publications/bim-files-to-download/>). Not committed: fetched by URL and sha256 as in `corpus/tier2/README.md`. Its Revit IFC has no Revit level parameters, so the oracle is Revit's storey containment (parts take their host's storey). rvt-rs exports 507 elements on 4 storeys and writes a level for 467 of them; 467 of 467 are Revit's storey, and every value is a recovered Level name. Housing_Concrete_BuildingPermit (99.8 MB): 1388 of 1401 agree (99.1%) once elements that Revit contains in a room (`IfcSpace`: furniture, sanitary terminals, generic models) take the room's storey; the 13 others are openings, which Revit puts on their host's storey. The test's storey oracle follows room containment for this reason. Office_Concrete_BuildingPermit: 12,232 of 12,783 (96%), measured with a standalone scanner against direct storey containment only. Housing_Timber_* recovers no Level ids on main, so it writes none. Attribution: BIM4LCA example buildings, CC BY-SA 4.0. The files are not redistributed in this repository. Report: `reports/element-framing/RE-172-level-parameters.md`. Clean-room: this finding comes from public Autodesk Revit 2024 sample files with Revit's own IFC4 export as the oracle and exported symbol names only; no SDK source and no decompiled or disassembled code was used. ## Added: stairs, beams and other elements with no association level (RE-174) - **Stairs:** `Base Level` and `Top Level` are read from the association record. Base Level is a `u32` at ElementId + 115, 121, 129 or 137, depending on the record variant, and Top Level is exactly 32 bytes later. They are written only when exactly one of the four positions gives two different recovered Levels. Otherwise see RE-176 below. - **Beams, braces, MEP terminals, lights and proxies whose association level is `0xffffffff`:** the level is read from the element record's counted id lists, through the existing `decode_reference_list`. It is the 2nd list if that list names a recovered Level, otherwise the 1st. A value is written only when exactly one recovered Level is named; for beams and members with two candidates, see RE-175 below. Beams and listed members get `Reference Level`; other classes get `Level`. Measured on a clean build, against Revit's IFC4 export by `Tag`. Values are equal to Revit / elements where Revit has the property; storeys and all earlier properties are unchanged. | file | Reference Level | stair Base + Top Level | other Level | |---|---:|---:|---| | racadvanced | 35 / 35 | 5 / 5 | proxies 40 / 40 | | rstadvanced | 395 / 395 | – | – | | rstbasic | 339 / 339 | 1 / 1 | – | | racbasic | – | 3 / 3 | proxy, lights, sanitary: all equal | | rmeadvanced | – | 0 of 4 written | proxies 512, lights 307, air terminals 28, sanitary 11: all equal | | Technicalschool | 35 / 35 | – | proxies 40 / 40 | There are no wrong values. On racbasic, 2 railings and 1 roof get a `Base Level` where Revit writes none. `tests/level_parameters.rs` also checks `Reference Level` (at least 30) and `Top Level` (at least 4) on racadvanced. Report: `reports/element-framing/RE-174-stair-and-listed-levels.md`. The same clean-room provenance applies. ## Added: beams whose record lists two Levels (RE-175) When the id list names more than one recovered Level, a beam's (`IfcBeam`) or member's (`IfcMember`) `Reference Level` is the one with the highest elevation. It is written only when every listed Level has an elevation and the highest is unique; otherwise nothing is written. Other classes are unchanged: applied to them, the rule wrote the upper Level as `Base Level` on 21 stairs where Revit has the lower one. Measured against Revit's IFC4 export by `Tag` (written / equal to Revit / elements where Revit has the property): | file | before | after | |---|---:|---:| | racadvanced | 35 / 35 / 38 | 37 / 37 / 38 | | Technicalschool | 35 / 35 / 38 | 37 / 37 / 38 | | rstadvanced | 395 / 395 / 399 | 397 / 397 / 399 | | rstbasic | 339 / 339 / 370 | 370 / 370 / 370 | Taking the lowest Level instead is wrong on all 35 tiebreak beams. There are no wrong values in any `Constraints` property across the 8 Autodesk samples and 12 BIM4LCA files; rmeadvanced, rmebasic and racbasic are unchanged. The ones still without `Reference Level` are 3 roofs (racadvanced, Technicalschool, racbasic) and 2 truss assemblies (rstadvanced). On BIM4LCA Office_Timber As-Built and BuildingPermit, written levels go from 36 to 83, and 83 of 83 are Revit's storey. DACH and Snowdon are not measured (no elements exported on main). `tests/level_parameters.rs`: the racadvanced `Reference Level` minimum is now 37, and `level_parameters_survey_are_revits` checks every model in `RVT_REVIT2024_SAMPLES_DIR` that has its Revit IFC beside it (zero wrong values, per-file minimums). Report: `reports/element-framing/RE-175-beam-reference-level-tiebreak.md`. The same clean-room provenance applies. ## Added: stairs whose association record gives no Base/Top pair (RE-176) A stair's element record lists its Base Level, its Top Level and, for some stairs, the Level above the top. For class `Stair` listing two or more recovered Levels, `Base Level` is the lowest listed Level and `Top Level` the next one above it, by recovered elevation. Written only when every listed Level has an elevation and the lowest three are at distinct elevations. Per stair, against Revit's `Constraints` (Snowdon measured with #737 applied locally, not part of this PR): | rule | right | wrong | skipped | |---|---:|---:|---:| | Base = lowest listed | 56 | 0 | 1 | | Top = second-lowest listed | 54 | 0 | 3 | | Top = highest listed | 41 | 13 | 3 | | control: Base = highest listed | 0 | 54 | 3 | On the 89 stairs where the association record already gives Base and Top, lowest = its Base and second-lowest = its Top on all 89. BIM4LCA (no `Constraints` set; reference = Revit's storey): lowest listed = storey for 72 of 72 stairs. Survey (written / equal to Revit / Revit has it): Technicalschool `Base Level` 196 / 190 / 195 -> 201 / 195 / 195 and `Top Level` 0 -> 5 / 5; rmeadvanced and rmebasic `Base Level` 141 / 141 / 149 -> 149 / 149 / 149 and `Top Level` 0 -> 8 / 8. No wrong values in any property on any file; nothing else changes. `level_parameters_survey_are_revits` now requires the stair `Top Level` counts on the five stair-bearing Autodesk samples. Not covered: `IfcStair`s that rvt-rs does not decode as class `Stair` (BIM4LCA Housing_Concrete 31 of 38, Office 2 of 16). Report: `reports/element-framing/RE-176-stair-levels-from-listed-levels.md`. The same clean-room provenance applies. ## Landing notes Merged with `main` by the maintainer. The BIM4LCA corpus row joins the single row that lists every BIM4LCA file the tests read, and `highest_level` was closed again after the merge cut it. The Core Interior witness observations and both project-count manifests count the Constraints sets this PR writes: `IFCPROPERTYSET` 2948 to 3802, taken from the PR's own CI artifact. The BIM4LCA and Revit 2024 sample comparisons in this description are the contributor's measurements; CI's corpora hold neither set, so `tests/level_parameters.rs` skips there.
…Identity Data and Phasing sets (#755) Writes the element's `Category`, family/type and `Phase Created` in the property sets Revit's IFC4 export uses. Closes #754. - **Occurrence:** `Other` (`Category`, `Family`, `Family and Type`, `Type`, `Type Id`) and `Phasing` (`Phase Created`), as `IfcLabel`. - **Type object:** `Other` (`Category`, `Family Name`) and `Identity Data` (`Type Name`), as `IfcText`, through `HasPropertySets`. Revit puts these on the type, not the occurrence. - **Category:** `m_builtinCategory` (element record `+0x12`) through a table of 57 BuiltInCategory ids with the English names Revit's export writes (`builtin_category_name` in `partition_element_records.rs`). No table entry, no value. - **Phase Created:** new `src/partition_phases.rs` reads phase names from their frame (`01 00 00 00 | u64 id | 56 x ff | 00 00 00 | u32 n | UTF-16 x n`), accepted only when the `ProjectPhase` class tag sits 38 bytes before the id or the frame is the element's own data and the id has an `OST_Phases` record. `attach_phases_created` takes the one phase id in the element record's reference list (RE-168); none or two phases writes nothing. - Family/type values come from the existing decode (RE-38) and are unchanged; only their names are added. Measured against Revit's IFC4 export by `Tag` (equal / elements where Revit has the property; no wrong values in any column): | file | Category | Phase Created | Family | Type | Type Id | |---|---:|---:|---:|---:|---:| | Technicalschool | 5403 / 5403 | 5401 / 5401 | 5354 / 5393 | 5354 / 5393 | 5354 / 5393 | | racadvanced | 5408 / 5408 | 5406 / 5406 | 5359 / 5398 | 5359 / 5398 | 5359 / 5398 | | racbasic | 424 / 427 | 424 / 424 | 411 / 424 | 413 / 424 | 413 / 424 | | rmeadvanced | 6483 / 6492 | 6477 / 6483 | 5223 / 6483 | 5223 / 6483 | 5223 / 6483 | | rmebasic | 6527 / 6536 | 6521 / 6527 | 5268 / 6527 | 5268 / 6527 | 5268 / 6527 | | rstadvanced | 904 / 904 | 904 / 904 | 904 / 904 | 904 / 904 | 904 / 904 | | rstbasic | 454 / 454 | 454 / 454 | 450 / 454 | 450 / 454 | 450 / 454 | `Family Name` and `Type Name` on the type objects: 22,948 of 25,471, none wrong. The family/type gap is mostly ducts and pipes (about 1,250 per rme file), which have no family/type on main either. Not covered: Revit 2023 and 2025, `Phase Demolished`, non-English category names. DACH and Snowdon Architectural export no elements on main (#736). With #737 applied locally (not part of this PR): DACH `Category` 2381 / 2395 and `Phase Created` 2370 / 2379, Snowdon 5657 / 5708 and 5666 / 5685, none wrong; Snowdon family/type none wrong; **DACH family/type 14 wrong** (12 stair runs typed `陇`, 2 walls with another wall's type), from the existing RE-38 decode. Test: `tests/category_type_phase.rs` (`RVT_REVIT2024_SAMPLES_DIR`, any `<name>.rvt` with its Revit `<name>.ifc`; skips otherwise). Every value written must equal Revit's, and `Category` and `Phase Created` must cover at least 99%. It fails on main (`Category 0 of 6609` on racadvanced and rmeadvanced) and passes here. `cargo fmt --check` and `cargo clippy --all-targets --all-features -- -D warnings` pass; the full suite passes except `ifc_synthetic_project::synthetic_project_emits_valid_ifc4`, which fails on main too. Report: `reports/element-framing/RE-177-category-type-phase.md`. Clean-room: public Autodesk Revit 2024 sample files with Revit's own IFC4 export as the oracle; `ProjectPhase` from the file's own schema stream. No SDK source and no decompiled or disassembled code was used. ## Landing notes Merged with `main` by the maintainer, after #751. The unit-test module this PR added to `src/partition_phases.rs` is left out, because CONTRIBUTING doesn't accept new unit tests and CI doesn't run them; `tests/category_type_phase.rs` stays. The Core Interior witness observations and both project-count manifests count the sets this PR writes (`IFCPROPERTYSET` 3802 to 5908), taken from the PR's own CI artifact. The Revit 2024 sample comparisons in this description are the contributor's measurements; CI's corpora hold no Revit export of those samples.
[Unreleased] becomes [0.5.0] — 2026-10-18, with an introduction, the contributors, and what to change when upgrading from 0.4. The community pull requests' entries are added and credited (#737, #738, #744, #751, #752, #753, #755, #757, #758), and the repeated Added, Changed, Fixed and Research headings are folded into one each, keeping every entry (107) and its order; everything from [0.4.0] down is unchanged. CITATION.cff said 0.1.2 (2026-04-20), though RELEASE.md has it agree with Cargo.toml at every tag. Its abstract now describes the project as the README does, without the "first open-source tool" and "verified against 11 releases" claims.
## Summary Prepare v0.5.0. Merging this is not the release: the release is the signed `v0.5.0` tag on the merged commit, which runs `publish.yml` (crates.io, PyPI, the release binaries and the container image). The tag waits for the maintainer's go-ahead. ## Motivation `main` is 0.4.0 plus everything under `[Unreleased]`: Revit 2026 projects (experimental), MEP ports, connections and systems, Revit's level, category, family, type and phase properties, rooms aggregated into their storeys, Snowdon Towers exporting again, and the first pull requests from outside contributors. Before 1.0 a breaking change bumps the minor version, and these are breaking for a 0.4 user: - The MSRV is 1.87 (was 1.85). - `rvt` has no `wasm` feature; the bindings are the `rvt-wasm` crate (C6). - Each `IfcSpace` is aggregated into its storey instead of contained in it (#744). - `ElemTableHeader::record_count` is a `u32` (#764). - Type objects take Revit's GlobalIds (RE-167). ## Changes - **Versions 0.4.0 → 0.5.0:** `rvt`, `rvt-py` and its pin, `rvt-wasm`, the `stream_evidence` pin, both lockfiles (only the workspace crates' version lines change), `.release-please-manifest.json` and `viewer/package.json`. - **`CHANGELOG.md`:** `[Unreleased]` becomes `[0.5.0] — 2026-10-18`. - An introduction, the contributors, and an **Upgrading from 0.4** section. - The community pull requests' entries are added and credited (#737, #738, #744, #751, #752, #753, #755, #757, #758). - The repeated Added, Changed, Fixed and Research headings, which later merges had appended, are folded into one each. All 107 entries are kept as written (checked as a multiset) and in their order, and everything from `[0.4.0]` down is byte-identical. - #778's clean-room policy change is added under Changed, so the section has 108 entries. - **`CITATION.cff`:** it said 0.1.2 (2026-04-20), though `RELEASE.md` has it agree with `Cargo.toml` at every tag. Its abstract now describes the project as the README does, without the "first open-source tool" and "verified against 11 releases" claims. - **Registry descriptions:** crates.io showed 0.4.0's description, which leaves out Revit 2023, and PyPI one that called element extraction and geometry "active research" and the export "document-level IFC4 scaffolding". `Cargo.toml` and `pyproject.toml` now say what the README says: typed elements from Revit 2023 to 2025 projects, 2026 experimental. - **Witnesses:** the IFC header carries the version (#417), so both Core Interior `rvt-rs.json` observations and their verdicts are refreshed from this pull request's CI run. ## Testing - CI on this pull request: every job `CI passed` requires, the witness replays among them. - On the tag, the publish workflow runs its own checks before anything is published: wheel install and model open on each OS, `cargo install` and the CLI sample smoke, the docs.rs build preview and the viewer load smoke. crates.io and PyPI publish only after all of them pass, and PyPI only after crates.io. ## Audit-honesty checklist - The docs keep describing 0.4.0 as the latest release until each 0.5.0 channel has been checked from what was published. That follows in a separate pull request (`docs/install.md`, `docs/python.md`, `docs/status.md`, `docs/supported-profile.md` and the README's release section). - crates.io's trusted publisher (repository DrunkOnJava/rvt-rs, workflow `publish.yml`, environment `crates-io`) has to be in place before the tag, as `docs/maintaining.md` says; it is a registry-side setting this repository cannot check. ## Legal and contribution hygiene N/A: release metadata only. Contributors are credited by their GitHub names in the CHANGELOG. ## Breaking changes Listed under Motivation, with the migration for each in the CHANGELOG's **Upgrading from 0.4**.
…hing names (#760) (RE-189) (#797) ## Summary `elem_table::declared_ids` declares each `Global/ElemTable` record's current id only: its second id on the 40-byte layout when that is not `0`, its first otherwise. Where the two differ, nothing in the file names the first id unless it is also another element's current id, so it no longer counts as declared on its own (#760, RE-189). ## Motivation #760 (found by @pinterbanget while landing #737): Snowdon Towers Architectural declares 84 ids that name no record. They are the first ids of the 84 records whose two ids differ, which `declared_ids` kept beside the second. The issue's bar for dropping them was: does anything in the file name a first id? If nothing does, dropping them is the fail-closed choice. ## Changes - **`src/elem_table.rs`:** `declared_ids` maps each record to its current id. Its doc states the measurement. - **`examples/probe_re189_first_id_references.rs`:** for every record whose ids differ, it searches every stream for both ids, as `u64` and `u32`, inflated where compressed. It names the partition chain record holding each partition hit, and it sorts the first ids by what names them. - **`reports/element-framing/RE-189-first-ids-name-nothing.md`**, and a CHANGELOG `[Unreleased]` Fixed entry. ## Testing The probe, Measure run [39157096050](https://github.com/DrunkOnJava/rvt-rs/actions/runs/39157096050) (`-f samples=true`). The Snowdon models are Autodesk's samples, fetched for the run and never stored. | | Snowdon Architectural | Snowdon Structural | |---|---:|---:| | Records whose ids differ | 84 | 27 | | First ids that are another element's current id | 0 | 7 | | Other first ids named in a project element record | 0 | 0 | | ... named only in loaded families' own documents (and, on Architectural, `Global/ContentDocuments`) | 43 | 2 | | ... named nowhere | 41 | 18 | None of the other 28 files with 40-byte records that Measure reads has a record whose ids differ. The change, Measure A/B run [39158195119](https://github.com/DrunkOnJava/rvt-rs/actions/runs/39158195119) (`-f samples=true`, base `main`): - **CI's 6 reference models:** every output, the IFC hash and GLB among them, is byte-identical. - **The 49 samples:** every `rvt-info` output and every export diagnostics file is identical, except one field on the two Snowdon models. `decoded_element_fraction` rises as its denominator loses the stray ids: 47,317 → 47,233 declared on Architectural, 16,591 → 16,571 on Structural. The corpus target that first showed this (`partition_record_chain::every_first_prologue_frame_starts_a_record_of_its_own_id`) runs only where Snowdon is in `RVT_PROJECT_CORPUS_DIR`, and CI's corpus does not include it, so this pull request's CI cannot show it passing. On these numbers, Architectural's declared set now equals the 47,233 ids that have a record. The rebase onto main after the A/B (#793) touches no Rust source. ## Clean room The changes in this PR are based on public byte observations of Autodesk's published sample projects and the magnetar and Drshelden models (sources 1 to 3). I have not used Autodesk SDK source, ODA SDK source, leaked internal documentation, NDA material, or decompiled internal Revit implementation code beyond public symbol exports, and I have not copied or translated code from revit-ifc. ## Breaking changes None in output. `declared_ids` returns fewer ids on files whose ElemTable records carry two different ids (two Snowdon models among the 55 measured). Closes #760
Summary
elem_table::detect_layoutnow picks the record size by the ElementId, the record's second id, instead of its first. Before this change, Autodesk's Snowdon Towers samples took the 12-byte fallback layout, andrvt-ifcexported 0 of Structural's 1,282 elements and 1 of Architectural's 6,056. Every other file reads the same layout as before.Motivation
Fixes #736, a regression from #559 (
5131dc7), found by git bisect.detect_layoutaccepts a record size when the stated records fit from0x06and the ids rise over the whole table, but it tested the first id at+0. On Snowdon the first id differs from the second on 27 (Structural) and 84 (Architectural) records, and it falls below its predecessor 2 and 3 times. So neither size passed, and every element record lost its ElementId (RE-30).The second id (
+4on 28 bytes,+20on 40) is the onedeclared_idsalready documents as the ElementId that partition records, owners and Revit's own export carry (RE-41). It rises strictly on every table I measured:The wrong size never passes on the second id either: 5,338 to 30,516 breaks at 28 B on the 40 B tables. On the 28 B tables, the 40 B layout doesn't fit.
Changes
src/elem_table.rs:detect_layoutreads the id atrecord_fields(stride).0(the second id), and the doc comment says why.tests/elem_table_frame.rs:id_secondary, which equalsid_primaryon every file this target read before;snowdon_tables_rise_by_element_idreads the two Snowdon samples when they are inRVT_PROJECT_CORPUS_DIR, and skips otherwise because they are not redistributable.CHANGELOG.md: a Fixed entry.Testing
tools/check-local.shpasses: fmt, clippy-D warnings, rustdoc, build, andverify-real-files.sh(232 passed).revit.downloads.autodesk.com: Snowdon Towers 2024 and rac_basic 2019/2022/2024, which match the SHAs pinned inresearch/autodesk-sample-projects.tsv.elem_table_frame::andelem_table_corpus::withRVT_SAMPLES_DIR(11 families),RVT_PROJECT_CORPUS_DIR(Einhoven, Core Interior and both Snowdon samples) andRVT_REQUIRE_CORPUS=1: all pass, including the new Snowdon target.elem_table_corpus::declared_element_ids_returns_sorted_deduped_setfails identically on unmodifiedmain120e2f9; it expects the first id to be 1, and fix(elem_table): read the table's records from 0x06 (#152) #559 made id 0 an ordinary record.tools/ci/test-targets.txtalready skips it.rvt-ifcoutput is identical tomain120e2f9apart from theFILE_NAMEandIFCOWNERHISTORYtimestamps: Snowdon Plumbing, Core Interior, Einhoven, and rac_basic 2019/2022/2024.The element counts match v0.4.0's export of the same files.
Audit-honesty checklist
Legal and contribution hygiene
Breaking changes
None.
Suggestion, not in this PR
Snowdon Towers is on the same Autodesk host as the 2016-2027 sample projects that
tools/fetch-autodesk-samples.shalready fetches, pinned by SHA, for a measurement run. Adding its Architectural, Structural and Plumbing files to that list would let the Measure workflow catch the next regression like this one.Related issues
Closes #736. Refs #559, #152.
🤖 Generated with Claude Code