Skip to content

red: B72 door and window type GlobalIds (scratch, do not merge) - #665

Closed
DrunkOnJava wants to merge 4 commits into
mainfrom
red/b72-door-type-gids
Closed

DrunkOnJava wants to merge 4 commits into
mainfrom
red/b72-door-type-gids

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Red run for B72's test on top of B60 (#663).


Note

Medium Risk
Changes IFC GlobalId assignment and type grouping in the export path; incorrect symbol reads would mis-identify types in downstream IFC consumers, but scope is limited to metadata and covered by corpus regression tests.

Overview
Implements RE-167 (B60): IFC type objects for family instances now use the GlobalId of the instance’s original FamilySymbol, matching Revit’s exporter, while the type’s Tag stays the symbol’s ElementId.

The partition walker adds attach_original_symbols (Revit 2024+), reading each instance’s original symbol from GElement data and emitting m_original_symbol. Export folds that into element_original_symbols, fills RevitGlobalIds.element_types, and the STEP writer splits type groups by that GlobalId and assigns it to emitted type entities (with deduping). Doors and windows are skipped on this path because Revit hashes flip into their type GlobalIds (B72); separate corpus tests assert non-door/window types (type_global_ids) and door/window types (door_type_global_ids) against reference IFC when RVT_PROJECT_CORPUS_DIR is set.

Reviewed by Cursor Bugbot for commit 1a98674. Configure here.

… (B60)

tests/type_global_ids.rs compares, for every element both exports relate
to a type, the type's GlobalId with Revit's, on the four RE1 models and Core
Interior. Door and window types are left out (B72).

Red on main (draft #662, run 37219969064, "Corpus health (tier 2)"):

  RE1-Architecture.rvt: 67 elements typed in both, 31 types' GlobalIds not Revit's; 5 doors and windows left out
  RE1-Mechanical.rvt: 49 elements typed in both, 37 types' GlobalIds not Revit's
  RE1-Plumbing.rvt: 123 elements typed in both, 54 types' GlobalIds not Revit's
  RE1-Electrical.rvt: 49 elements typed in both, 2 types' GlobalIds not Revit's
  2024_Core_Interior.rvt: 716 elements typed in both, 278 types' GlobalIds not Revit's; 138 doors and windows left out
  panicked at tests/type_global_ids.rs:166:5:
  RE1-Architecture.rvt: 31 of 67 typed elements' types have another GlobalId than Revit's; first: ["351456 (IFCFURNITURETYPE): Revit 3144CP5Ub2qhBtGD1R3koT, rvt-rs 3144CP5Ub2qhBtGD1R3koW", ...]
…s GlobalId, one type object per original symbol (B60)

RE-167 (Measure runs 37218947202 and 37219379143): Revit's exporter writes a
family instance's type with the GlobalId of the instance's original symbol
(ExporterIFCUtils.GetOriginalSymbol) and the Tag of its symbol. The instance's
GElement data object holds that FamilySymbol's ElementId 20 bytes before its
end. On the RE1 models that gives Revit's type GlobalId for every family
instance outside doors and windows: 162 of them, the symbol itself for most
and another FamilySymbol (often the instance's id plus one) for furniture,
fittings, mullions and panels. Doors and windows take a hash of it with the
door's flip (B72), not read yet, and keep their symbol's.

The schema pass records each family instance's original symbol (one value
across its GElement objects, naming a FamilySymbol); RevitGlobalIds gains
element_types, an element's type GlobalId where it is not its symbol's; and
the writer writes one type object per symbol, entity and GlobalId, as Revit
does: RE1's 10 mullions share Tag 446539 across 9 type objects.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Split types can share fallback GlobalIds
    • When a split type group cannot claim its Revit GlobalId, the synthetic stable GUID now includes that original-symbol GlobalId so colliding groups no longer share the same fallback key.

Create PR

Or push these changes by commenting:

@cursor push a3172c696d
Preview (a3172c696d)
diff --git a/src/ifc/step_writer.rs b/src/ifc/step_writer.rs
--- a/src/ifc/step_writer.rs
+++ b/src/ifc/step_writer.rs
@@ -2784,7 +2784,8 @@
             };
             let type_gid = match revit {
                 Some(global_id) if used_gids.insert(global_id.clone()) => global_id,
-                _ => gid(&["type", entity_name, &tag]),
+                Some(global_id) => gid(&["type", entity_name, &tag, &global_id]),
+                None => gid(&["type", entity_name, &tag]),
             };
             let type_el_id = self.id();
             self.emit_entity(

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1a98674. Configure here.

Comment thread src/ifc/step_writer.rs
.cloned(),
};
let type_gid = match revit {
Some(global_id) if used_gids.insert(global_id.clone()) => global_id,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split types can share fallback GlobalIds

Low Severity

Type groups are now split by original-symbol GlobalId as well as type_id, but a group that cannot take a unique Revit GlobalId still falls back to gid keyed only by entity name and type_id. Two groups that share a type and entity and both miss a unique Revit id therefore emit the same type GlobalId, which IFC forbids.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a98674. Configure here.

@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Red output recorded in #666's test commit.

@DrunkOnJava DrunkOnJava closed this Oct 4, 2026
@DrunkOnJava
DrunkOnJava deleted the red/b72-door-type-gids branch October 4, 2026 17:50
DrunkOnJava added a commit that referenced this pull request Oct 4, 2026
…s exporter gives it (B72)

tests/door_type_global_ids.rs compares, for every door and window both
exports relate to a type, the type's GlobalId with Revit's, on the four RE1
models and Core Interior.

Red with B60 (draft #665, run 37221217853, "Corpus health (tier 2)"):

  RE1-Architecture.rvt: 5 doors and windows typed in both, 5 types' GlobalIds not Revit's
  2024_Core_Interior.rvt: 138 doors and windows typed in both, 138 types' GlobalIds not Revit's
  panicked at tests/door_type_global_ids.rs:164:5:
  RE1-Architecture.rvt: 5 of 5 doors' and windows' types have another GlobalId than Revit's; first: ["416336 (IFCDOORSTYLE): Revit 1PKhJ34R4m_wvuiYRV$TaB, rvt-rs 0ptz7pvLP4Fx0ykvinP_cA", ...]
DrunkOnJava added a commit that referenced this pull request Oct 4, 2026
…ith the door's flip from its host wall (B72) (#666)

Revit hashes a door's or window's type GlobalId from its original
symbol's GlobalId and the door's flip: MD5 of `<symbol
gid>Sub-element:Flipped: <True|False>`, with ` InAssembly: False` from
revit-ifc 25.4 on (a Revit 2025 or later file; Core Interior's 2024
export has no suffix). The flip comes from the door's box centre and
facing against its host wall's axis (revit-ifc DoorWindowInfo); a door
with no host is not flipped.

Red test on draft #665; the output is in the test commit. Green: Corpus
health run 37225506986, door_and_window_types_take_revits_global_ids ok
on RE1 x4 and Core Interior, type_objects_take_revits_global_ids ok.
Core Interior's witness observation is refreshed from CI's own artifact
(IFCDOORTYPE 3 -> 10: a door type is written once per flip).

Bugbot's typed-no-geometry thread: that mode writes no type objects at
all (measured, run 37224651451), so no flip-dependent GlobalId is
written there; logged as B74 for when that mode gains types.
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