Skip to content

Take the root of an element from its record in the project block - #190

Merged
mahach666 merged 1 commit into
mainfrom
feat/own-record-class
Nov 12, 2026
Merged

mahach666 merged 1 commit into
mainfrom
feat/own-record-class

Conversation

@mahach666

Copy link
Copy Markdown
Collaborator

Summary

Third step of the read path onto the partition framing, after #187 and #189 (the records of the project's block on PartitionFraming.Framed).

In a file without its own class schema (Revit 2020 and 2022), the class of an element and the stair and railing facts the reader keeps per root object (StairComponentSource: OwnedElementClassRoots, WalkedElementClassRoots, the stair membership, run input, name parameters, parameter definitions and the railing host) were counted from every block the stream walk met for the id. The walk meets the copies of an id in the documents of loaded families and byte runs inside other items, and it misses roots it does not reach; an element with two counted roots, or none, got no class. This is what issue 47 describes: removing unrelated superseded records moved the class from one element to another.

Now, when every partition stream of such a file is read by its framing:

  • The root of each element is its channel-102 record in the project's own block, in its current copy (RvtFileReader.RecordFramedRoots), handed to StairComponentSource.Record once per element before the walk. The walk no longer counts roots.
  • The location line of a wall is read from its root record once every root is counted, not from the blocks the walk meets (a copy of the wall's id elsewhere could otherwise replace it).
  • A record is copied out of its segments on its own (an item can run into the next segment of its chain); the stream is not concatenated.
  • A file with a stream whose framing does not hold, and every file with its own class schema, keep the walk counts.

Refs #47

Measured

23 project files without their own class schema (releases 2020 and 2022), exported with the base (#189) and with this branch:

Elements whose class root changes 0
Elements that lose their class 0
Elements that get a class 59, in 7 files
IFC identical in all 23
Compact JSON identical in 16; in 7 the 59 elements carry the name of their class and its usual properties instead of an empty name
Export report identical in 20; in 3 the elements skipped as unknown are listed under their class

The 59 elements are views, schedules, sketch planes, extents, styles, a wall, a rebar, dimensions and the like. In the file of issue 47, 17 elements get their class (16 schedules and a family); through the family, 8 types of lighting fixtures get their family name and 10 viewports their IFC export parameters. Of the 34 elements the comparison printed (up to 12 per file), the walk never reached the root of 32 and counted two or three roots for 2.

The counts of the stair membership, railing host, run input and name parameter roots are the same with both ways in all 22 files compared that way. The table of parameter definitions counted once is smaller (for example 1,360 to 518): the walk also counted the parameter definitions of the family documents; the reader looks definitions up by the ids a stair names, and no output changed.

Not covered

  • Files with their own class schema (Revit 2021 and 2023 and later) read through the Revit 2022 layout keep the walk counts; their records carry the file's own class numbers and the rewritten stream is not cut by the framing.
  • The other uses of the walk (the first class met per id in ElemClassIdx, about thirty other per-root sources, the geometry blocks) and the block parser of issue 48 are unchanged.
  • The largest file was exported, but not compared root by root.

Verification

  • Full test suite on net8.0 with the final code: 10816 tests, 10667 passed, 141 skipped, 8 failed. The 8 failures are bounding-box tests (ValidatedTests 2, ApiTests.Proxy289128_* 3, ElementHeaderBoundingBoxTests 3) that fail the same way on main without this change. In one earlier full run of the same code ContainerRewriterSampleTests.CompactJson_OfTheCopy_EqualsTheJsonOfTheSource failed as well; it passed on its own and in the two other full runs, and the cause was not found (the test writes to a temporary folder shared by every test run on the machine).
  • New tests: the root of an element is its record in the project's block and a copy of its id in a family document does not make it a duplicate (counted per block met, as the walk does, it would); on TESTFILE.rvt, read with and without the removal of superseded copies, every element held once keeps its root, and an arc wall whose root the walk does not reach gets its class (this assertion fails with the walk counts).
  • A review with a second check of every finding. Confirmed and fixed: the wall location line was still read during the walk against the new counts, so a later copy of the wall's id could replace it (now read from the root record); the size check allowed a stream a little longer than the largest array (now each record is copied on its own). After the fixes the 23 files were exported again: identical to the export before the fixes.
  • net10.0 was not built or tested.

In a file without its own class schema, the class of an element and the stair and railing facts kept per root object were counted from every block the stream walk met for the id, which includes copies of the id in the documents of loaded families and byte runs inside other items, and misses roots the walk does not reach. When every partition stream is read by its framing, the root of each element is now its channel-102 record in the project's own block, in its current copy, and the location line of a wall is read from that record. Files with a stream whose framing does not hold, and files with their own class schema, keep the walk counts.

On 23 files of the releases 2020 and 2022, 59 elements in 7 files get a class and none loses or changes one; the IFC is identical, the compact JSON names those elements.

Refs #47
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