Compare commits

...

1 Commits

Author SHA1 Message Date
Petru Conduraru 1eaaa4363d Bonsai: guard drawing with no document reference in get_sheet_references (#8036)
get_sheet_references calls get_drawing_document, which returns None when the
drawing has no associated IfcRelAssociatesDocument, then compares
reference.Location == drawing_reference.Location, raising
"AttributeError: 'NoneType' object has no attribute 'Location'" during
drawing activation.

A drawing with no document reference cannot be referenced by any sheet, so
return the empty list before the comparison loop. Behavior when a reference
exists is unchanged (the guard is unreachable in that case).

Fixes #8036. Fixes #7266.

Generated with the assistance of an AI coding tool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 15:26:11 +03:00
+4
View File
@@ -2830,6 +2830,10 @@ class Drawing(bonsai.core.tool.Drawing):
def get_sheet_references(cls, drawing: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
sheet_references: list[ifcopenshell.entity_instance] = []
drawing_reference = cls.get_drawing_document(drawing)
# A drawing with no associated document reference cannot be referenced
# by any sheet, so there is nothing to compare against (see #8036, #7266).
if drawing_reference is None:
return sheet_references
for sheet in tool.Ifc.get().by_type("IfcDocumentInformation"):
if not sheet.Scope == "SHEET":
continue