mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 15:07:38 +00:00
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>
This commit is contained in:
@@ -2830,6 +2830,10 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
def get_sheet_references(cls, drawing: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
def get_sheet_references(cls, drawing: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||||
sheet_references: list[ifcopenshell.entity_instance] = []
|
sheet_references: list[ifcopenshell.entity_instance] = []
|
||||||
drawing_reference = cls.get_drawing_document(drawing)
|
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"):
|
for sheet in tool.Ifc.get().by_type("IfcDocumentInformation"):
|
||||||
if not sheet.Scope == "SHEET":
|
if not sheet.Scope == "SHEET":
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user