Skip to content

Seed legacy type-level material relation GlobalIds from material identity - #193

Merged
mahach666 merged 1 commit into
IOExtend:mainfrom
AndreyStartsev:fix/legacy-type-material-relation-globalids
Nov 12, 2026
Merged

mahach666 merged 1 commit into
IOExtend:mainfrom
AndreyStartsev:fix/legacy-type-material-relation-globalids

Conversation

@AndreyStartsev

Copy link
Copy Markdown
Contributor

Problem

In IfcProfile.Legacy, AssociateTypeObjectMaterials seeded the GlobalId of type-level IfcRelAssociatesMaterial entities from the STEP entity number of the relating IfcMaterial, IfcMaterialList or IfcMaterialLayerSet (type-materials:{relatingMaterial} / type-layer-set:{layerSet}). Adding or removing unrelated elements or properties earlier in the file shifted those STEP #N numbers and changed the GlobalId of every type-level material relation, even though product-level material relations (materials:{materialKey} and material-layers:{group.Key}) already used stable Revit material/layer keys.

Closes #88

Changes

  • Track (int EntityId, string Seed) in relatingMaterialByProductEntity (materialKey, e.g. "0", "700", "710,720") and layerSetByProductEntity (ownType.TypeId or group.Key).
  • Seed AssociateTypeObjectMaterials relation GlobalIds from type-materials:{materialSeed} and type-layer-set:{layerSetSeed} instead of STEP entity IDs.
  • Update ComponentType_ReceivesTheMaterialOfItsFirstInstance (type-materials:0) and add LegacyTypeMaterialRelationGlobalIds_StayStableWhenEarlierStepEntitiesShift verifying single-material (IfcMaterial) and multi-material (IfcMaterialList) type-level relations stay identical when prepended elements/properties shift STEP entity IDs, while IfcProfile.Current keeps its existing MD5("{projectGlobalId}IfcRelAssociatesMaterial:{firstRelatedGlobalId}") seed.
  • Record the intentional one-time GlobalId change for legacy type-level material relations under ### Breaking changes in CHANGELOG.md.

Export comparison

  • IfcProfile.Current (default) and JSON exports: byte-for-byte unchanged (ApplyCurrentMaterialRelationGlobalIds rewrites material relation GlobalIds in Current profile, and JSON exports do not touch IfcExporter).
  • IfcProfile.Legacy: product-level IfcRelAssociatesMaterial entities (materials:{materialKey}, material-layers:{group.Key}) are unchanged; type-level IfcRelAssociatesMaterial entities change their GlobalId once from IfcGuid.FromName("type-materials:<stepEntityId>") to IfcGuid.FromName("type-materials:<materialElementIds>") and remain stable across unrelated STEP entity shifts.

Verification

  • dotnet build RvtIO.slnx -c Release — 0 errors, 0 warnings in src/.
  • dotnet test tests/RvtIO.Tests/RvtIO.Tests.csproj -c Release --no-build --filter "FullyQualifiedName~IfcExporterTypeObjectsTests|FullyQualifiedName~HostMaterialUsageTests|FullyQualifiedName~HostTypeLayerSetGroupingTests|FullyQualifiedName~IfcMepMaterialsTests" — 298 passed, 0 failed (net8.0 and net10.0). Private-fixture [SkippableFact] tests outside this filter are skipped when RVTIO_TEST_FILES is unset.
  • dotnet docfx docfx.json --warningsAsErrors — 0 warnings, 0 errors.

@mahach666
mahach666 merged commit 0b99172 into IOExtend:main Nov 12, 2026
4 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.

Legacy IFC profile: GlobalIds of type-level material relations depend on the STEP entity number

2 participants