Skip to content

fix(ifc)!: derive generated GlobalIds from identity, not file position (#400) - #402

Merged
DrunkOnJava merged 1 commit into
mainfrom
fix/stable-fallback-globalids
Sep 27, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
fix/stable-fallback-globalids

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #400.

What changes

Every GlobalId rvt-rs generates (for entities Revit's export gives none) was 0rvtrs + the STEP entity index, so any added or removed entity renumbered everything after it. Each is now a SHA-256 over a fixed namespace (rvt-rs ifc GlobalId v1), the document's Unique Document GUID from BasicFileInfo, and the entity's own identity, as an RFC 9562 version-8 UUID in IFC's 22-character form (revit_global_ids::compress_ifc_guid, the same encoder RE-48 uses).

Entity Identity key
building element without a Revit GlobalId its Tag (ElementId) + which of the entities sharing that Tag it is (slab pieces #331, curtain parts); untagged: entity type + name + occurrence
opening the GlobalId of the element filling it
rel voids / rel fills the opening's GlobalId
property set / rel defines by properties owning element's GlobalId + set name + occurrence
material association (profile/layer usage) element's GlobalId
material association (single material) material name + occurrence
element aggregate the whole's GlobalId
spatial containment the storey's GlobalId (or the building)
storey without a Revit GlobalId name + occurrence
project, site, building, spatial aggregates, classification associations fixed roles (+ source, code)

Revit's own GlobalIds (RE-48) are used exactly as before. RevitGlobalIds gains document: Option<String> (serde default), filled by the exporter.

Evidence (real entry point: rvt-ifc on a real file)

The pair from the issue: Snowdon Towers Architectural (Revit 2024, local only, no licence) exported by builds of 344deb3 and ebba730, i.e. before and after RE-75's curved walls, compared with the new tools/ifc_globalid_stability.py (products matched by entity + Tag + occurrence).

GlobalIds duplicated tagged products that kept their id all GlobalIds surviving
before this PR 20,149 0 6,095 of 6,248 (147 openings and 6 slabs changed) 7,740 of 20,149
with this PR (applied to both commits) 20,149 0 6,248 of 6,248 20,149 of 20,149

tools/ifc_globalid_stability.py --require-stable exits 1 on the old pair and 0 on the new one. No duplicate GlobalId in the new exports of Core Interior, the four RE1 models or Einhoven.

Compatibility

One-time change: every generated GlobalId differs from v0.2.0's. On Snowdon Towers that is the 155 products without a Revit GlobalId (site, building, 147 openings, 6 slab pieces) plus every relationship and property set; the 6,093 products carrying Revit's own GlobalId are unchanged. Anything keyed on the old 0rvtrs… ids needs one re-import. Recorded in CHANGELOG [Unreleased] under Changed.

Checks

  • tools/check-local.sh: passed (fmt, clippy -D warnings, rustdoc -D warnings, 204 test suites).
  • tests/revit_global_ids.rs and tests/level_names.rs with RVT_PROJECT_CORPUS_DIR set (Core Interior + RE1): passed, so Revit's own GlobalIds are untouched.
  • tests/fixtures/synthetic-project.ifc and synthetic-structural.ifc regenerated with DUMP_IFC/DUMP_IFC_STRUCTURAL; the diff is GlobalIds plus the two header timestamps a dump always rewrites. tools/ci/ifc_schema_arity.py passes on both (IfcOpenShell 0.8.5).
  • IfcOpenShell reads every GlobalId in the new Snowdon (20,149) and Core Interior (3,446) exports as a valid, unique IfcGloballyUniqueId (ifcopenshell.guid.expand).
  • Existing step_writer tests: the two make_guid tests went with the function; step_guids_are_unique_across_entities now checks every rooted entity's GlobalId instead of grepping the removed prefix. No new unit tests.

Legal and contribution hygiene

  • Derived only from this repository's own code and public specifications (RFC 9562, IFC GlobalId encoding); no Autodesk or ODA material.

Note

Medium Risk
Breaking change to IFC GlobalId semantics for all rvt-rs–generated entities; downstream tools keyed on old 0rvtrs IDs must re-import, though Revit-native element GlobalIds stay the same.

Overview
Breaking IFC export change (#400): Generated GlobalIds no longer use the 0rvtrs + STEP entity index scheme, which shifted whenever unrelated entities were added or removed. They are now SHA-256–derived from a fixed namespace, the document’s Unique Document GUID (RevitGlobalIds.document), and per-entity identity keys (ElementId/tag + occurrence, opening → filling element, relationships → participants, etc.). Revit-rebuilt GlobalIds (RE-48) are unchanged.

The STEP writer assigns these stable IDs across project/site/building, storeys, elements, openings, void/fill chains, property sets, material associations, aggregates, and spatial containment. Fixtures and docs reflect the new IDs; tools/ifc_globalid_stability.py compares two exports for stability.

One-time migration: Anything keyed on old generated 0rvtrs… IDs (relationships, property sets, openings, etc.) needs a re-import; values differ from v0.2.0 even when geometry is unchanged.

Reviewed by Cursor Bugbot for commit ca27bfd. Configure here.

#400)

Entities Revit's export gives no GlobalId were numbered by their STEP entity
index, so adding one profile point renumbered every GlobalId after it:
RE-75's curved walls changed the ids of all 147 openings and 6 slab pieces
on Snowdon Towers, and 12,409 of its 20,149 GlobalIds. Each is now a
SHA-256 of a fixed namespace, the document's Unique Document GUID and the
entity's own identity (ElementId and piece, the filling element for an
opening, the participants for a relationship), as a version-8 UUID in IFC
form. Revit's own GlobalIds are unchanged.

Snowdon exported before and after RE-75 now keeps all 20,149 GlobalIds.
tools/ifc_globalid_stability.py makes that comparison repeatable.

BREAKING CHANGE: every generated GlobalId differs once from v0.2.0's.
@cursor

cursor Bot commented Sep 27, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_09a5cd9d-1f15-4527-93ab-87a1c41141c3)

@DrunkOnJava
DrunkOnJava merged commit 6efed45 into main Sep 27, 2026
23 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/stable-fallback-globalids branch September 27, 2026 19:30
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.

Synthetic GlobalIds shift whenever earlier geometry changes

1 participant