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
This commit is contained in:
Andrej730
2024-08-28 12:21:23 +05:00
parent 4e1a956830
commit 1aed2a6b3c
+4 -7
View File
@@ -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))