Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,50 @@ API between minor releases.
from. An element that placed that definition, or a later build from the block, could hold the same data twice, and which
elements did could differ between two reads of one file. The IFC export uses this data for triangle-set bodies and for
some base quantities.
- A graphic style (`GStyleElem`) no longer gets a name from bytes that only look like one, from a string stored near its
id or from a linked type, and no `FamilyName` through such a link. The class stores no name and has no type, so its
`FamilyName` is now `null`, and so is its `Name` unless the element name table of the file holds one. String built-in
parameters are no longer read from byte runs that only look like a block header, with no closing copy of the block
size. Such a run could attach the text behind it to an element that does not store it. Values that were copied from
those names change with them: an element that took its name or type name through a link to a graphic style now has its
own name or none, an IFC `Structural Material` that pointed at a graphic style is written as the element id instead of
that name, and the fill pattern guess of a wall, which accepts a named element, no longer accepts a graphic style and
takes the next candidate or none.
- A category element (`CategoryElem`) takes its `Name` from the name its category stores, and has none when the file
stores an empty name, a repeated block or no name that could be read, unless the element name table, a name the file
stores for the element itself or the schema walk of the file holds one. Before, a string found in its blocks or near
its id, which is nearly always the name of a neighbouring element, or the name of a type it was linked to, became its
name. Like a graphic style it has no type, so it takes no type name and no `FamilyName` through a link.
- A guess of the type of an element that names a graphic style or a category element makes no type. Neither stores a
type, so an element that took one as its type took the name, the family and the values behind it from something that is
no type. This covers the type id taken from the references or from a type parameter, the type parameters
(`ELEM_TYPE_PARAM`, `SYMBOL_ID_PARAM`, `ELEM_FAMILY_AND_TYPE_PARAM`) voted from the references of an element, the dim
style of a weak dimension and the type that `RvtDocument` takes from the references of an element that has none. Such
an element now has no type id and no such type parameter instead (its `TypeId` is -1), and
`FilteredElementCollector.WhereElementIsElementType` and `TypeElementIds` no longer count a graphic style or a category
element that only a guess named as a type. The other guesses are unchanged, and where the guess was of another category
than the element, the type parameters follow the type id of the element. What the file stores in the block of an
element stays as it was read.
- The structural material (`STRUCTURAL_MATERIAL_PARAM`, the IFC `Structural Material`) is taken only from a material
element (`MaterialElem`) instead of any element that carries the category of materials, which an element also gets from
the elements it refers to. An IFC `Structural Material` that named a graphic style, a category element or another
element that is no material now names the material or is left out, and the values derived from the material (thermal and
analytical properties) change with it. The fill pattern guess of a wall accepts only a fill pattern element
(`FillPatternElem`) instead of any named element in the id range, so it no longer names a dimension style or a
parameter element.
- A graphic style (`GStyleElem`) and a category element (`CategoryElem`) get no type from a guess. The file stores no
type for either, and the references they hold were taken for one: the lowest-id element of the same category among
them, or the voted one. They now have `TypeId` -1 and none of `ELEM_TYPE_PARAM`, `SYMBOL_ID_PARAM` and
`ELEM_FAMILY_AND_TYPE_PARAM` unless the file stores one; `ELEM_FAMILY_PARAM`, where the file stores a family, stays.
What they took through that type goes with it: `CLEAR_COVER_*`, `FAMILY_LEVEL_PARAM`, `STRUCTURAL_MATERIAL_PARAM`, the
fill pattern, and the user and shared parameters of the elements of that type, which they were given as if they were
one of them. An element that only such a guess named as its type is no longer in `TypeElementIds` or
`FilteredElementCollector.WhereElementIsElementType`. An element whose own type guess took such a known type as
evidence may now get another type or none, since the evidence was no type.
- A material (`MaterialElem`) keeps the name the reader gave it. `RvtDocument` replaced it with the name of the element
its `ELEM_TYPE_PARAM` names, which for a material is a guess, unless a graphic style happened to name the material as
its type. The name pass of the reader already left materials alone; an element that only carries the category of
materials, which it gets from what it refers to, is still named by its type.

## [0.6.3] - 2026-11-20

Expand Down
6 changes: 4 additions & 2 deletions src/RvtIO/Export/ValidatedElementNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ internal static int Apply(RevitFileInfo info, JsonReadFacts state,
/// <summary>The validated names of the element in priority order. A named element (a type, level or material) reports
/// its own name and nothing else; only an occurrence with no name of its own reports the name of its type, as the
/// Revit API does. A type element (it owns a Symbol-subclass root, <see cref="JsonReadFacts.SystemTypeRoots"/>) has no
/// type: the link it carries points at another symbol, so without a validated name of its own it has none.
/// type: the link it carries points at another symbol, so without a validated name of its own it has none. A graphic
/// style and a category element have no type either.
/// Two different names in the result would contradict each other.</summary>
internal static IEnumerable<Validation> Candidates(
Element element, IReadOnlyDictionary<int, Element> byId, IReadOnlyDictionary<int, int> counts, JsonReadFacts state)
Expand All @@ -89,7 +90,8 @@ internal static IEnumerable<Validation> Candidates(
named = true;
yield return validation;
}
if (named || element.Id == 0 || state.SystemTypeRoots.ContainsKey((uint)element.Id)) yield break;
if (named || element.Id == 0 || state.SystemTypeRoots.ContainsKey((uint)element.Id)
|| state.StoresNoType((uint)element.Id)) yield break;
foreach (Validation validation in TypeNames(element, byId, counts, state))
yield return validation;
}
Expand Down
8 changes: 8 additions & 0 deletions src/RvtIO/Internal/JsonReadFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ internal class JsonReadFacts
{
/// <summary>First block class ID (low 16 bits) seen per element in the continuous walk.</summary>
public Dictionary<uint, ushort> ElemClassIdx { get; } = new();
/// <summary>The element is a GStyleElem (class 2050). Its schema chain stores no name and no type, so a name found in its
/// blocks, near its id or behind a type link belongs to something else.</summary>
internal bool IsGraphicStyle(uint eid) => ElemClassIdx.GetValueOrDefault(eid) == 2050;
/// <summary>The element is a GStyleElem or a CategoryElem (class 632). Neither stores a type, so a type link on it is a
/// guess and a name or family behind it is not its own.</summary>
internal bool StoresNoType(uint eid) => IsGraphicStyle(eid) || IsCategoryElement(eid);
/// <summary>The element is a CategoryElem (class 632). Its name is the one its Category stores.</summary>
internal bool IsCategoryElement(uint eid) => ElemClassIdx.GetValueOrDefault(eid) == 632;
/// <summary>The file's own schema, or null for the shipped 2022 layout.</summary>
public FileSchema? WideSchema { get; set; }
/// <summary>The element's own name from its root in the file's schema.</summary>
Expand Down
8 changes: 8 additions & 0 deletions src/RvtIO/Model/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,14 @@ internal string? ValidatedStairComponentTypeName
/// (<see cref="RvtIO.Parsing.NativeTypePointers"/>), so type guesses must not replace it.</summary>
internal bool TypeFromNativePointer { get; set; }

/// <summary>The id of the graphic style or the category element that a guess of this element's type named (0: none did).
/// Neither is a type: the element has none through that guess, and no other guess puts a type in its place.</summary>
internal int TypeGuessOnNoType { get; set; }

/// <summary>The id of the graphic style or the category element that the guess of <see cref="TypeId"/> named (0: none did),
/// which leaves the element without a type id.</summary>
internal int TypeIdOnNoType { get; set; }

/// <summary>Closed-shell quantities of the solids at the Coarse, Medium and Fine detail levels (index 0, 1, 2); null at a level whose
/// solids are not all closed shells of plane faces. See <c>ElementBuilder.ApplyInstanceQuantities</c>.</summary>
[JsonIgnore]
Expand Down
4 changes: 3 additions & 1 deletion src/RvtIO/Parsing/BlockParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,9 @@ internal static void CollectBipStrings(byte[] d, ParsingState state)
if (dataSize == 0) { pos++; continue; }
if (pos + 16 + (int)dataSize > d.Length) break;

if (ElementIdEncoding.IsSupported(eid))
// A block repeats its size at its end. Without that copy the bytes only read as a header, and the strings behind
// them are not those of the id they happen to hold.
if (ElementIdEncoding.IsSupported(eid) && BitConverter.ToUInt32(d, pos + 12 + (int)dataSize) == dataSize)
{
int ds = pos + 16, de = ds + (int)dataSize;
int limit = de - 9;
Expand Down
Loading
Loading