Skip to content

Give a graphic style and a category element no type from a guess - #359

Merged
mahach666 merged 4 commits into
mainfrom
fix/categoryelem-stored-names
Dec 4, 2026
Merged

mahach666 merged 4 commits into
mainfrom
fix/categoryelem-stored-names

Conversation

@mahach666

Copy link
Copy Markdown
Collaborator

What changes and why

A graphic style (GStyleElem, class 2050) and a category element (CategoryElem, class 632) store no type, and a graphic style stores no name either, yet the reader gave them both from guesses, and then took names, families and values from the things those guesses pointed at.

  • Names. A graphic style takes its name only from the element name table of the file; the string walk of BlockParser takes a block only with its closing size. A category element takes its name from the name its category stores (CategoryNames), not from a string near its id or from a linked type. Neither takes a type name or a FamilyName through a type link.
  • Type guesses. A guess of the type of an element that names such an element makes no type: the type id from references, the voted type parameters, the dim style of a weak dimension, and the type RvtDocument takes for an element that has none. A graphic style or a category element itself gets no guessed type either. They now have TypeId -1 and none of ELEM_TYPE_PARAM, SYMBOL_ID_PARAM, ELEM_FAMILY_AND_TYPE_PARAM unless the file stores one; a family the file stores (ELEM_FAMILY_PARAM) stays.
  • What they took through a guessed type goes with it: CLEAR_COVER_*, FAMILY_LEVEL_PARAM, STRUCTURAL_MATERIAL_PARAM, the fill pattern, and the parameters of the elements of that type. TypeElementIds and FilteredElementCollector.WhereElementIsElementType no longer count them as types when only a guess named them.
  • STRUCTURAL_MATERIAL_PARAM (and so the IFC Structural Material) comes only from a MaterialElem; the fill pattern guess of a wall only from a FillPatternElem.
  • A material keeps its own name. RvtDocument replaced the name of a MaterialElem with the name of the element its ELEM_TYPE_PARAM names, which is a guess for a material; only a graphic style that happened to name the material as its type protected it. The exemption is by class (MaterialElem), not by the category of materials, which other elements inherit through their references and which still take the name of their type.

Behavior that changes for callers:

  • TypeId, the type parameters and the values copied through them on those two kinds of element.
  • WhereElementIsElementType and TypeElementIds for elements that only such a guess named as a type.
  • Elements whose own type guess used such an element as evidence (a vote, a known type) may get another type or none.
  • The names of materials, and values copied from the old names.

How it was checked

  • dotnet build RvtIO.slnx -c Release has no warnings. The pinned SDK 10.0.100 was removed from the machine by an IDE update while this was being checked, so the last build and test runs used SDK 11.0.100 on a copy of the sources without global.json; that build passes but prints new warnings from the newer SDK. Earlier runs on SDK 10 were green.
  • dotnet test, net10.0 and net8.0, without private files: no failures (net10.0 12474 passed, net8.0 12470 passed) before the final test-expectation edit below.
  • dotnet test with the private fixtures (RVTIO_TEST_FILES): net8.0 fails only the four tests that already fail on main with these fixtures (three ElementHeaderBoundingBoxTests.StoredOutline_IsTheElementBoxOfEveryRelease cases and RvtWriterSampleTests.SaveAs_...). net10.0 gave the same four plus ContainerRewriterSampleTests.CopyThrough_..., which failed with "not enough space on the disk" and passed on rerun.
  • Exports of the same files before and after: the element dumps (names, type ids, IsType, every parameter) of the whole private sample set were compared before and after, and every difference traced to one of the rules above; none is unexplained. IFC and JSON exports were not compared separately for this change.
  • No Revit models, customer data or vendor files are added. Tests use synthetic documents and invented strings.

Two ReferenceApiTests on a private fixture (SearchBetonString, CheckWall290112) expected the old material names and counts; they now expect the names the file stores. They are skipped without the private files, which is why runs without them did not show it.

The type-guess rules were mutation-checked (each mutation makes a new test fail), and the material exemption has a test that failed before the fix.

A graphic style (GStyleElem, class 2050) stores no name and no type, yet it got
both from guesses, and its FamilyName followed a guessed type link.

- The string walk of BlockParser accepted any bytes that read as a block header.
  A block repeats its size at its end; without that copy the bytes are not a
  block, and the text behind them went to the element whose id they happened to
  hold. A block is now taken only with the closing size.
- The name of a style comes from the element name table of the file and from
  nowhere else: not from strings found in its blocks, not from strings near its
  id, not from a linked type. Its type name and family name are not filled
  through a type link either.

Values copied from those names change with them: elements that took a name
through a link to a style, the IFC Structural Material that pointed at a style
(now the element id, not the style's name) and the fill pattern guess of a wall,
which no longer accepts a style as a candidate.

Tests use invented strings and synthetic blocks. Three ApiTests counts on a
private fixture drop because styles no longer carry names.
A graphic style (GStyleElem, class 2050) and a category element (CategoryElem,
class 632) store no type, yet the reader gave them one from their references,
and took the name, the family and the values behind it from something that is
no type.

- A category element takes its name from the name its category stores
  (CategoryNames), not from a string near its id or from a linked type.
- A guess of the type of an element that names a graphic style or a category
  element makes no type: the type id from references, the voted type
  parameters, the dim style of a weak dimension and the type that RvtDocument
  takes for an element that has none. Such an element has no type id and none of
  ELEM_TYPE_PARAM, SYMBOL_ID_PARAM and ELEM_FAMILY_AND_TYPE_PARAM unless the file
  stores one; a family the file stores (ELEM_FAMILY_PARAM) stays.
- The two kinds of element no longer own a guessed type, so what they took
  through it goes: CLEAR_COVER_*, FAMILY_LEVEL_PARAM, STRUCTURAL_MATERIAL_PARAM,
  the fill pattern and the parameters of the elements of that type. They are no
  longer counted as types by TypeElementIds and WhereElementIsElementType when
  only a guess named them.
- STRUCTURAL_MATERIAL_PARAM comes only from a MaterialElem, and the fill pattern
  guess of a wall only from a FillPatternElem.
- A MaterialElem keeps the name the reader gave it. RvtDocument replaced it with
  the name of the element its ELEM_TYPE_PARAM names, which is a guess for a
  material, unless a graphic style happened to name the material as its type.
  The exemption is by class, not by the category of materials, which other
  elements inherit through their references.

On the 53 private samples every difference of the element dumps before and
after is explained by one of these rules; elements that only such a guess
supported as evidence (votes, known types) may get another type or none.
Two ApiTests on a private fixture expected the old material names and counts
and now expect the names the file stores. Tests use synthetic documents.
@mahach666
mahach666 merged commit 11683ea into main Dec 4, 2026
5 checks passed
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