Skip to content

Commit 9ac1f61

Browse files
committed
Deduplicate aggregates in select_aggregate clipboard query
All selected objects sharing the same aggregate would produce duplicate entries in the clipboard query. Aggregates are now collected into a dict keyed by id before selection and query generation. Generated with the assistance of an AI coding tool.
1 parent 51edb20 commit 9ac1f61

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/bonsai/bonsai/bim/module/aggregate/operator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,21 @@ def invoke(self, context, event):
280280
return self.execute(context)
281281

282282
def execute(self, context):
283-
all_parts = []
283+
aggregates = {}
284284
for obj in context.selected_objects:
285285
element = tool.Ifc.get_entity(obj)
286286
if element:
287287
aggregate = ifcopenshell.util.element.get_aggregate(element)
288288
if aggregate:
289-
all_parts.append(aggregate)
289+
aggregates[aggregate.id()] = aggregate
290290
obj.select_set(False)
291291
else:
292292
pass
293293
if not element:
294294
obj.select_set(False)
295295

296+
all_parts = list(aggregates.values())
297+
296298
if self.select_parts:
297299
selected_parts = []
298300

0 commit comments

Comments
 (0)