From 1eaaa4363dd6e10681f66239748331b3b40a58b9 Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Sat, 11 Jul 2026 15:26:11 +0300 Subject: [PATCH] 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 --- src/bonsai/bonsai/tool/drawing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index c43aa9e73e..1ba78a497d 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -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