Skip to content

fix(elem_table): read the table's records from 0x06 (#152) - #559

Merged
DrunkOnJava merged 6 commits into
mainfrom
fix/b02-elemtable-records
Oct 3, 2026
Merged

DrunkOnJava merged 6 commits into
mainfrom
fix/b02-elemtable-records

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Global/ElemTable is now read as the table it is (#152). After the u16 tag and the u32 record count at 0x02, the records start at 0x06 and close with their owner:

Releases Record Layout
2008 to 2023 28 B [u32 id][u32 id][16 B][u32 owner]
2024 on 40 B [u64 id][12 B][u64 id][u64 owner][u32]

This is STE1200's frame. puzzbobb measured it on 30 files from 2008 to 2027 (#152, issuecomment-5939876282 and 5951500722).

What was wrong

elem_table::parse_records framed records from 0x1E, 24 bytes into each record:

  • It never returned the table's first record.
  • On every 2024 and later file and on every family, it returned a last record read from the bytes after the table: (0, 0) on the projects, and id 18 after 7,259 on the 2016 family. That declared an id 0 that no record holds.
  • On 28-byte projects it returned one record too few: 2,614 of Einhoven's 2,615.

What changes

  • parse_records returns exactly the stated count from 0x06, ids rising over the whole table, each record with its own owner. A family's first record is owned by element 17.
  • detect_layout takes the record size (28 or 40) at which the stated records fit with rising ids, with the shorter tail breaking a tie. That also reads the 2008 to 2012 projects, where the marker scan took an 84-byte stride; no such file is in our corpora.
  • revit_global_ids: the episode is at +8 of the record on both sizes. These are the same bytes as +0x18 and +0x0c of the old frames, so no GlobalId changes.
  • ElemRecord::previous_ids (from fix(elem_table): the declared ids include the table's first record (#152, #421) #553, unreleased) is always None, because the first record is records[0].
  • header.record_count stays a u16, the low half of the count; no measured file has 65,536 records. parse_records reads the full u32.

Tests

The commits are separate, so each can be reviewed on its own:

  1. test(elem_table): the new real-file target tests/elem_table_frame.rs, written from the table's description. Its red run on main (draft PR red run: elem_table_frame (B02, do not merge) #558, run 37115866869) is in the commit message:
    • 2016 family: ids rise strictly, but record 1595 has id 18 after 7259 (of 1596)
    • Einhoven: parse_records returns the 2615 records the table states, left: 2614, right: 2615
  2. Five existing tests in tests/elem_table_corpus.rs move to the 0x06 reading. The maintainer approved this before the reader changed, and each changed value is listed in the commit.
  3. The inline mirror suite of src/elem_table.rs is deleted (336 lines; unit-test option (c), B23). One pure-logic test stays.
  4. The fix.

Reported by puzzbobb and STE1200 (#152, #421).

One consequence, fixed here

partition_type_parameters::value_blocks ended a value block at a mark only when the u64 before it was a declared id. The old reader declared a false id 0 on every 2024 and later file, so marks owned by 0 ended blocks. Once 0 is declared only where it is an element, RE1 Architecture's curtain wall type (474504) took the next block's Type Mark '2'. Measure run 37116833078 showed this as the only output difference across 6 models, 11 families and 36 samples. Revit's export writes no Type Mark, so it cannot decide the value.

A mark owned by 0 now starts an unowned block unless 0 is declared. It still ends the block before it, and its values go to no type.

Measured

Measure run 37117234625 compared head against main, with the families and samples:

  • the IFC of all 6 reference models is byte-identical;
  • every scorer, rvt-info and diagnostics.json output is identical on all 6 models, 11 families and 36 sample projects.

The new reading's invariants on 54 files (2014 to 2027) are in RE-147 (run 37117029420): every file reads its stated count, ids rise, and every set owner is declared, with no self-owner or loop.

A real-file target from the table's description (STE1200's frame,
puzzbobb's measurements on #152): parse_records returns the u32 count at
0x02, ids rise strictly, owners are declared ids with no self-owner or
loop, and a family's first record is owned by element 17.

Red on main (c5f7e43), draft PR #558, run 37115866869:

  build + real files / ubuntu-latest / stable (also windows-latest):
    thread 'family_tables_hold_every_stated_record' panicked at
    tests/elem_table_frame.rs:69:9:
    2016 family: ids rise strictly, but record 1595 has id 18 after 7259
    (of 1596)
    test result: FAILED. 1 passed; 1 failed

  Corpus health (tier 2 - external):
    thread 'project_tables_hold_every_stated_record' panicked at
    tests/elem_table_frame.rs:60:5:
    assertion `left == right` failed: Revit_IFC5_Einhoven.rvt:
    parse_records returns the 2615 records the table states
      left: 2614
     right: 2615
    test result: FAILED. 1 passed; 1 failed

Both are the expected reasons: the last frame of a family is read from
the trailer (id 18 after 7259), and a 28-byte project table walks one
record short.
Approved by the maintainer on 2026-10-03, before the reader changes. The
five tests pinned the 0x1E framing, which starts 24 bytes into each
record: it missed the first record and read one more from the tail.
Each changed value, against the table read from 0x06 (STE1200's frame,
puzzbobb's measurements on #152, the committed Core Interior excerpt):

- elem_table_record_origin_is_flush_with_the_stream_end (excerpt):
  start 0x1E -> 0x06, owner offset 4 -> 28, a 24-byte tail instead of a
  flush end, offsets 0x1E.. -> 0x06.., ids [1,2,3,133205,133206,0] ->
  [0,1,2,3,133205,133206] (the last 0 was the tail), the record's zero
  u32 and FF x8 owner at +24/+28 instead of +0/+4, owner None.
- family_files_use_the_project_layouts: start 0x06; ids [1,3] ->
  [0,1,3]; ids rise over the whole table (no "terminator": it was the
  trailer); pairs agree on records[1..], the same records as before;
  record 0's owner Some(17), record 1's None (the old records[0]).
- project_2023_file_parses_all_declared_records: 2614 -> 2615, equal to
  record_count; ids 0,1,2,3; offset 0x06.
- project_2024_file_parses_all_declared_records: a 24-byte tail after
  the array; record 0 at 0x06 with id 0 (AllProjectPhases on Core
  Interior); ids and second ids 1,2,3 on records[1..4].
- owner_ids_are_declared_element_ids: Einhoven parses 2615, not 2614;
  the owner counts (339, 22,368) stay.

No assertion is dropped or loosened: the record sets checked are the
same records, now at their true positions.
Unit-suite option (c), area elem_table: 16 of the 17 inline tests in
src/elem_table.rs mirror the implementation. They build synthetic byte
buffers in the parser's own 0x1E framing and assert its layout fields,
or call the private flush_origin; one (header_has_element_count) asserts
the bytes it just wrote. None ran in CI (tools/ci/test-targets.txt bans
unit tests). index_by_element_id_keeps_first_duplicate stays: it checks
documented behaviour from outside.

Coverage of the area is the real-file targets elem_table_frame (new) and
elem_table_corpus, which read every family of 2016 to 2026 and the
Einhoven and Core Interior projects; this deletion lands only with their
green run on this PR.

Lines removed: 336.
After the u16 tag and the u32 record count at 0x02, Global/ElemTable's
records start at 0x06 and close with their owner: [u32 id][u32 id][16 B]
[u32 owner] through Revit 2023, [u64 id][12 B][u64 id][u64 owner][u32]
from 2024 (STE1200's frame, measured by puzzbobb on 30 files, 2008-2027).

parse_records framed from 0x1E, 24 bytes into each record: it never
returned the first record, returned a last one read from the tail on
every 2024+ file and every family ((0, 0), (18, 0)), and one too few on
28-byte projects. It now returns the stated count from 0x06, at the
record size where they fit with rising ids, each with its own owner.

- detect_layout: start 0x06, stride 28 or 40 by rising ids over the
  whole table (shorter tail on a tie), marker_offset = the owner's
  offset; the marker scan, flush_origin and id_progression_layout go.
- previous_ids is always None and declared_ids no longer reads it.
- revit_global_ids: the episode is at +8 of the record on both sizes,
  the same bytes as +0x18 / +0x0c of the old frames, so GlobalIds do not
  change.
- partition_schema_mvp: a comment's +0x1c becomes the record's +12.
- docs/elem-table-record-layout-2026-04-21.md marked superseded.

Decided here: header.record_count stays a u16 (the low half of the u32
count; no measured file has 65,536 records) so callers that compare it
with a u16 keep compiling; parse_records reads the full u32. An owner of
0 still reads as unset, as family files write 0 for unset, although id 0
is an ordinary element on Einhoven and Core Interior.
…efore it (#152)

value_blocks cut the partition at a value-block mark only when the u64
before it was a declared id. Every 2024 and later file declared a false
id 0 (read from the bytes after the ElemTable), so marks owned by 0 cut
the blocks; with the table read from 0x06, 0 is declared only where it is
an element, and on RE1 Architecture the curtain wall type (474504) took
the next block's Type Mark '2' (Measure run 37116833078: the only output
difference across 6 models, 11 families and 36 samples; Revit's export
writes no Type Mark to decide it). A mark owned by 0 now starts an
unowned block unless 0 is declared, so it cuts the block before it as
before, and its values go to no type.
@DrunkOnJava
DrunkOnJava merged commit 5131dc7 into main Oct 3, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/b02-elemtable-records branch October 3, 2026 10:47
DrunkOnJava added a commit that referenced this pull request Oct 3, 2026
…y and every file of 2016 to 2027 (#152) (#568)

This answers #152's open evidence items: a 2014 family and a 2026
project with set owners. It runs on the reader that #559 moved to
`0x06`.

- `research/public-families.tsv` pins the Stertil 2014 family STE1200
pointed to on #152: the zip and the `.rfa` inside it, each by sha256 and
size.
- `tools/fetch-public-families.sh` fetches it for a Measure run and
never stores it. A host it cannot reach is NOT MEASURED; a hash that
differs fails.
- `measure.yml` fetches it with the family corpus when `families` is
set.
- `examples/probe_re147_elem_table_invariants.rs` prints the table's
invariants.
- The report is
`reports/element-framing/RE-147-elemtable-on-2014-to-2027.md`.

Measure run 37117029420 read 54 files. On every one, the stated count
was read, ids rise, every set owner is declared, and no record is
self-owned or in a loop.
- The 2014 family has 28-byte records, 11,331 of them. Its first record
is 1274 with an unset owner, and all 10,208 owners are declared.
- The 2026 `rac_basic` project has 8,401 records, and all 3,884 owners
are declared.
- The record size changes once, between 2023 and 2024.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Adds research probes, pinned external fetch scripts, and CI workflow
steps; no changes to core `elem_table` parsing in this diff.
> 
> **Overview**
> Adds **RE-147** evidence for #152: a new probe
(`probe_re147_elem_table_invariants`) that checks `Global/ElemTable`
invariants (stated count vs records read, rising ids, owner
declarations, self-ownership, loops) and a report documenting **positive
results on 54 files** from a Measure run (2014 Stertil family through
2027 samples, plus reference models).
> 
> Extends the **`families` Measure path** with maker-published Revit
families: `research/public-families.tsv` pins the Stertil 2014 `.rfa`
(zip and file hashes), `tools/fetch-public-families.sh` downloads and
verifies them (unreachable hosts are skipped with a warning; hash
mismatch fails the step), and `measure.yml` fetches into the family
corpus directory alongside `phi-ag/rvt`. Changelog documents the
findings, including **28-byte records through 2023 and 40-byte from
2024**.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c84b922. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
DrunkOnJava pushed a commit to pinterbanget/rvt-rs that referenced this pull request Oct 18, 2026
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]>
DrunkOnJava pushed a commit that referenced this pull request Oct 18, 2026
…id (#737)

## Summary

`elem_table::detect_layout` now 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, and `rvt-ifc` exported 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_layout` accepts a record size when the stated records fit from `0x06` and 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 (`+4` on 28 bytes, `+20` on 40) is the one `declared_ids` already documents as the ElementId that partition records, owners and Revit's own export carry (RE-41). It rises strictly on every table I measured:

| File | Revit | Layout | Breaks in first id | Breaks in second id | Owners not among second ids | Owners not among first ids |
|---|---|---|---|---|---|---|
| Snowdon Towers Sample Structural | 2024 | 40 B | 2 | 0 | 0 | 13 |
| Snowdon Towers Sample Architectural | 2024 | 40 B | 3 | 0 | 0 | 42 |
| Snowdon Towers Sample Plumbing | 2024 | 40 B | 0 | 0 | 0 | 0 |
| 2024_Core_Interior (magnetar-io) | 2024 | 40 B | 0 | 0 | 0 | 0 |
| Revit_IFC5_Einhoven (magnetar-io) | 2023 | 28 B | 0 | 0 | 0 | 0 |
| rac_basic_sample_project 2019 / 2022 / 2024 | 2019 / 2022 / 2024 | 28 / 28 / 40 B | 0 | 0 | 0 | 0 |
| rac_basic_sample_family 2016-2026 (phi-ag/rvt) | 2016-2026 | | 0 | 0 | 0 | 0 |

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_layout` reads the id at `record_fields(stride).0` (the second id), and the doc comment says why.
- `tests/elem_table_frame.rs`:
  - checks rising ElementIds and owners on `id_secondary`, which equals `id_primary` on every file this target read before;
  - new `snowdon_tables_rise_by_element_id` reads the two Snowdon samples when they are in `RVT_PROJECT_CORPUS_DIR`, and skips otherwise because they are not redistributable.
- `CHANGELOG.md`: a Fixed entry.

## Testing

- [x] `tools/check-local.sh` passes: fmt, clippy `-D warnings`, rustdoc, build, and `verify-real-files.sh` (232 passed).
- [x] Verified end to end on real Revit files: commands and results below.
  - Files:
    - Autodesk's published samples from `revit.downloads.autodesk.com`: Snowdon Towers 2024 and rac_basic 2019/2022/2024, which match the SHAs pinned in `research/autodesk-sample-projects.tsv`.
    - magnetar-io/revit-test-datasets (MIT).
    - phi-ag/rvt families.
  - `elem_table_frame::` and `elem_table_corpus::` with `RVT_SAMPLES_DIR` (11 families), `RVT_PROJECT_CORPUS_DIR` (Einhoven, Core Interior and both Snowdon samples) and `RVT_REQUIRE_CORPUS=1`: all pass, including the new Snowdon target.
    - `elem_table_corpus::declared_element_ids_returns_sorted_deduped_set` fails identically on unmodified `main` `120e2f9`; it expects the first id to be 1, and #559 made id 0 an ordinary record. `tools/ci/test-targets.txt` already skips it.
- [ ] Witness verdicts: N/A. No exporter code changed. On every file that was not affected, `rvt-ifc` output is identical to `main` `120e2f9` apart from the `FILE_NAME` and `IFCOWNERHISTORY` timestamps: Snowdon Plumbing, Core Interior, Einhoven, and rac_basic 2019/2022/2024.
- [ ] Performance: N/A.

```text
rvt-ifc "Snowdon Towers Sample Structural.rvt"      main 120e2f9: 0 elements (1,271 records skipped, RE-30)   this branch: 1,282 elements on 12 storeys
rvt-ifc "Snowdon Towers Sample Architectural.rvt"   main 120e2f9: 1 element  (6,082 records skipped, RE-30)   this branch: 6,056 elements on 18 storeys
rvt-elem-table "Snowdon Towers Sample Structural.rvt"
  main 120e2f9:  layout: Implicit (12 B stride, no owner field)  first record offset: 0x30
  this branch:   layout: Explicit (40 B stride, 8-byte owner field at record +28, ...)  first record offset: 0x6
```

The element counts match v0.4.0's export of the same files.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR: no new claims beyond restoring what v0.4.0 exported.
- [x] No limitation resolved or introduced beyond the regression itself.
- [x] Commit message describes what changed and why.
- [x] No emojis in code, docs or commit messages.
- [x] No private paths, personal email addresses or internal jargon in committed files.
- [ ] Reverse-engineering finding: N/A. This applies RE-41's existing finding to layout detection; the measurements are in the table above.

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0.
- [x] No Autodesk proprietary source, decompiled internals, or NDA'd SDK content. Everything here comes from byte observation of the files listed above.
- [x] No new fixtures; the new target reads corpus files only when present.

## 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.sh` already 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.
@puzzbobb puzzbobb mentioned this pull request Oct 26, 2026
DrunkOnJava pushed a commit that referenced this pull request Oct 26, 2026
Acceptance item 1 of #421: "`bbox_marker` derives the marker from
`RevitFile::schema_classes` and is cross-checked against the 2024 and
2025 constants". On all 84 2024 to 2027 files I have, the marker from
each file's own schema equals the release's constant.

**What changes.** Every scan that needs the bbox marker now gets it from
`file_bbox_marker(rf, release)`:

- The marker is the one the file's schema gives (`schema_bbox_marker`,
RE-80: `[tag of Outline][0xFF x4][tag of ElementParents]`).
- The release's measured constant (`bbox_marker`) is the cross-check. If
the schema and the constant disagree, the file isn't scanned (fail
closed).
- If the schema doesn't parse, the constant is used. A release with no
constant needs the schema.
- `supports_revit_version` no longer depends on a constant being
recorded. It is only the proven-shape list (2024 to 2027).

`file_bbox_marker` already existed, but it returned the constant, and
only some scans called it. Before this patch, these callers read the
per-release table directly:

- `partition_names::compute_element_names`
- `partition_schema_mvp::attach_stair_names`
- `partition_type_records::scan_type_records`
- `partition_level_records::level_records` (64-bit path)
- `partition_type_parameters` / `partition_type_materials`, which only
use it as a "supported?" test and now call `supports_revit_version`

The `BBOX_MARKER*` constants and `bbox_marker` stay as the cross-check
table. The 2024-only legacy helpers that take `&BBOX_MARKER` are left
alone.

**Measurement.** The probe below, on 93 files (the phi-ag/Autodesk
samples, Core Interior, the RE1 set, Einhoven and 68 2025 projects):

| release | files | schema marker | `ElementHeader` | = constant | =
`file_bbox_marker` |
|---|---:|---|---:|:---:|:---:|
| 2024 | 5 | `46 01 ff ff ff ff ab 05` | 1439 | ✓ | ✓ |
| 2025 | 68 | `59 01 ff ff ff ff d3 05` | 1479 | ✓ | ✓ |
| 2026 | 4 | `61 01 ff ff ff ff f1 05` | 1509 | ✓ | ✓ |
| 2027 | 7 | `64 01 ff ff ff ff 10 06` | 1540 | ✓ | ✓ |

On every one of the 84 files, `record_prologue_constant(schema marker)`
(ElementParents x12) is the schema's `ElementHeader` tag, the `u16` that
each record chain header carries (RE-35).

**One finding for older releases.** That a 12 rule doesn't hold before
2019:

| release | ElementParents | ElementHeader | difference |
|---|---:|---:|---:|
| 2016 | 1210 | 1201 | 9 |
| 2017 | 1227 | 1218 | 9 |
| 2018 | 1268 | 1259 | 9 |
| 2019–2023 | | | 12 |

This is harmless today, because the 32-bit path
(`partition_element_records_2023`) takes the header tag from the schema.
But `record_prologue_constant` shouldn't be used for a 2016 to 2018
file. The patch says so in its doc comment, and the test below pins the
gap on each 2016 to 2023 family.

**Test.** `tests/schema_bbox_marker.rs` (registered in
`tests/integration/main.rs` and `tools/ci/test-targets.txt`) asserts
three things on each file:

- schema marker == `bbox_marker(release)`;
- `file_bbox_marker` returns it;
- the prologue == `ElementHeader`.

It runs on the 2024 to 2026 phi-ag families (`RVT_SAMPLES_DIR`, so CI
runs it) and on every project in `RVT_PROJECT_CORPUS_DIR`. A third test
checks the ElementParents − ElementHeader gap on the 2016 to 2023
families: 9 on 2016 to 2018, 12 from 2019. All three skip absent files.

**Checks**, on `3d2df24`, with the changelog fragment
`changelog.d/changed/re421-schema-marker.md`:

- rustfmt `--check`: clean;
- clippy `--all-features -D warnings` (lib, integration, probe): clean;
- `cargo check` with `-D warnings -D unnameable_types`: clean;
- `cargo test -p rvt --lib --test integration` on the local corpora: 134
+ 290 passed, the one failure being the stale test below;
- `tools/check-local.sh`: all gates passed.

**Also in this PR: a stale test.** On the full suite one test failed, on
unpatched `3d2df24` too:
`elem_table_corpus::declared_element_ids_returns_sorted_deduped_set`.
Since #553 and #559 the declared ids include the table's first record,
at `0x06`, which on Einhoven is id 0, but the test still expected the
first id to be 1. CI hadn't caught it because
`tools/ci/test-targets.txt` skipped the test by name (added in #428,
before the fix). The second commit makes the test expect ids 0 and 1
first and removes the skip, so CI runs it again. All six
`elem_table_corpus` tests pass.

**Still per-release tables:**

- `elevation_marker`;
- the Level `record_marker(revit_version)` table. `level_records` no
longer uses it on the 64-bit path, but it's still pub.

`schema_elevation_marker` exists, so the same change could be made for
those. Also, `schema_classes` isn't memoised, so each scan re-reads the
schema. That costs about 0.1 s per file in a debug build (Core Interior
0.10 s, Snowdon 0.14 s), which is small, but caching it on `RevitFile`
would be a tidy follow-up.

<details>
<summary>Probe: <code>examples/probe_421_schema_marker.rs</code> (one
JSON line per file)</summary>

```rust
//! #421, item 1: the element-record marker each file's schema gives, against
//! the release's measured constant.
//!
//! One JSON object per file: `release`, `schema` (the marker from
//! `Outline` and `ElementParents`, RE-80), `constant` (`bbox_marker`),
//! `header_tag` (the schema's `ElementHeader`) and `prologue`
//! (`record_prologue_constant` of the schema's marker), and `scanned`, the
//! marker `file_bbox_marker` hands the scans.
//!
//! Usage:
//!   cargo run --profile ci --example probe_421_schema_marker -- FILE.rvt ...

use rvt::RevitFile;
use rvt::research::partition_element_records as per;
use rvt::research::partition_element_records_2023::record_marker;

fn hex(marker: Option<[u8; 8]>) -> String {
    marker.map_or_else(
        || "null".into(),
        |m| format!("\"{}\"", m.map(|b| format!("{b:02x}")).join(" ")),
    )
}

fn main() {
    for path in std::env::args().skip(1) {
        let file = std::path::Path::new(&path)
            .file_name()
            .map(|n| n.to_string_lossy().into_owned())
            .unwrap_or_default();
        let mut rf = match RevitFile::open(&path) {
            Ok(rf) => rf,
            Err(e) => {
                println!("{{\"file\":{file:?},\"error\":{:?}}}", e.to_string());
                continue;
            }
        };
        let release = rf.basic_file_info().map(|i| i.version).unwrap_or(0);
        let schema = record_marker(&mut rf);
        let marker = schema.map(|(m, _)| m);
        println!(
            "{{\"file\":{file:?},\"release\":{release},\"schema\":{},\"constant\":{},\
             \"header_tag\":{},\"prologue\":{},\"scanned\":{}}}",
            hex(marker),
            hex(per::bbox_marker(release)),
            schema.map_or_else(|| "null".into(), |(_, t)| t.to_string()),
            marker.map_or_else(
                || "null".into(),
                |m| per::record_prologue_constant(&m).to_string()
            ),
            hex(per::file_bbox_marker(&mut rf, release)),
        );
    }
}
```

</details>
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.

1 participant