Skip to content

Commit 88daa83

Browse files
committed
Concatenate all selected values in select_similar
When multiple objects are selected, _generate_clipboard_query previously only used the first reference value. Now all values are joined with " + " so the clipboard query reflects every selected object (e.g. GlobalId = "A" + GlobalId = "B"). Generated with the assistance of an AI coding tool.
1 parent 2ad30a0 commit 88daa83

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ def execute(self, context):
15191519
f"{verb} all objects that share the same ({self.key}) value(s) from {len(reference_values)} reference object(s).",
15201520
)
15211521

1522-
self._generate_clipboard_query(reference_values[0] if reference_values else None, key)
1522+
self._generate_clipboard_query(reference_values, key)
15231523

15241524
return {"FINISHED"}
15251525

@@ -1568,17 +1568,22 @@ def _calculate_sum(self, context, key):
15681568
bpy.context.window_manager.clipboard = str(total)
15691569
self.report({"INFO"}, f"({total}) was copied to the clipboard.")
15701570

1571-
def _generate_clipboard_query(self, value, key):
1571+
def _generate_clipboard_query(self, values, key):
15721572
key = "PredefinedType" if key == "predefined_type" else key
1573-
if value is True:
1574-
value = "TRUE"
1575-
elif value is False:
1576-
value = "FALSE"
1573+
if not values:
1574+
return
15771575

1578-
if isinstance(value, list) and value:
1579-
result = ", ".join(f'{key} = "{item}"' for item in value)
1580-
else:
1581-
result = f'{key} = "{value}"'
1576+
def format_value(value):
1577+
if value is True:
1578+
return f'{key} = "TRUE"'
1579+
elif value is False:
1580+
return f'{key} = "FALSE"'
1581+
elif isinstance(value, list) and value:
1582+
return ", ".join(f'{key} = "{item}"' for item in value)
1583+
else:
1584+
return f'{key} = "{value}"'
1585+
1586+
result = " + ".join(format_value(v) for v in values)
15821587

15831588
bpy.context.window_manager.clipboard = result
15841589
self.report({"INFO"}, f"({result}) was copied to the clipboard.")

0 commit comments

Comments
 (0)