From 1aed2a6b3c0c91dc25cd62257008f0f641b14217 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 28 Aug 2024 12:21:23 +0500 Subject: [PATCH] Fix error not excluding annotations from other drawings after 3848a21 Mentioned in #5233 Also some refactor: - checking IfcProduct instead of IfcProject. Not sure when this issue occur in general but if it occurs then it might fail for other non-IfcProducts too, not just IfcProject - small performance optimization --- src/bonsai/bonsai/tool/drawing.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 0b8dc7533e..e9f6ec315d 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -1669,20 +1669,17 @@ class Drawing(bonsai.core.tool.Drawing): elements = {e for e in (elements & base_elements) if e.is_a() != "IfcSpace"} updated_set = set() - for i in elements: # exclude annotations to avoid including annotations from other drawings if not i.is_a("IfcAnnotation"): updated_set.add(i) # add aggregate too, if element is host by one - if i.Decomposes: - aggregate = i.Decomposes[0].RelatingObject + if decomposes := i.Decomposes: + aggregate = decomposes[0].RelatingObject # remove IfcProject for class iterator. See https://github.com/IfcOpenShell/IfcOpenShell/issues/4361#issuecomment-2081223615 - if not aggregate.is_a("IfcProject"): + if aggregate.is_a("IfcProduct"): updated_set.add(aggregate) - - # After the iteration is complete, update elements with updated set - elements.update(updated_set) + elements = updated_set # add annotations from the current drawing annotations = tool.Drawing.get_group_elements(tool.Drawing.get_drawing_group(drawing))