Skip to content

Concatenate selections#7940

Open
theoryshaw wants to merge 15 commits intov0.8.0from
Concatenate_selections
Open

Concatenate selections#7940
theoryshaw wants to merge 15 commits intov0.8.0from
Concatenate_selections

Conversation

@theoryshaw
Copy link
Copy Markdown
Member

@theoryshaw theoryshaw commented Apr 15, 2026

Branch: Concatenate_selections

Overview

This branch standardizes how Bonsai's "select similar" operators handle multiple selected objects. Previously, most operators either used only the active/first object, ignored duplicates, or built clipboard queries inside loops (producing overwrites or single-item output). All affected operators now collect their relevant entities from the full selection, deduplicate by entity id, and write a single clipboard query joining all values with + — consistent with IFC selector query syntax.


bim.select_similar — search/operator.py

Previously only reference_values[0] was passed to _generate_clipboard_query, so only the first selected object's value appeared in the clipboard.

Now all reference values are passed and joined with +.

Example: Select two walls and click "Select Similar" on GlobalId:

# Before
GlobalId = "1BDpUFH1P7$8huSfztD7Kp"

# After
GlobalId = "1BDpUFH1P7$8huSfztD7Kp" + GlobalId = "2yrtTmJoD5gvf_wIjwsNxp"


bim.select_ifc_class — search/operator.py

The clipboard was set and reported inside the per-class loop, overwriting on each iteration. The separator was also , rather than +.

Now the clipboard is written once after the loop with + as the separator.

Example: Select an IfcWall and an IfcSlab, then click "Select IFC Class":

# Before (last iteration wins, reported twice)
IfcWall, IfcSlab

# After (written once)
IfcWall + IfcSlab


bim.select_similar_container — spatial/operator.py

Only context.active_object's container was used. No clipboard output existed at all.

Now all selected objects are iterated, containers are deduplicated by entity id, elements from all containers are selected, and a clipboard query is generated.

Example: Select objects from Level 1 and Level 2, then click "Select Similar Container":

# Before
(no clipboard output, only active object's container used)

# After
location = "Level 1" + location = "Level 2"


bim.select_aggregate — aggregate/operator.py

When multiple parts of the same aggregate were selected, the aggregate was appended to a plain list multiple times, producing duplicate entries in the clipboard query.

Aggregates are now collected into a dict keyed by entity id before selection and query generation.

Example: Select three parts all belonging to the same IfcElementAssembly "Truss-A":

# Before
parent = "Truss-A" + parent = "Truss-A" + parent = "Truss-A"

# After
parent = "Truss-A"


bim.select_by_material — material/operator.py

The most involved change. The operator only used the explicit material prop (a single material ID set by the UI button), with no awareness of other selected objects. Layer set usages were not resolved to specific layers.

Now the operator derives materials from all selected objects. When the clicked material is an IfcMaterial within a layer set, its layer index is detected and the corresponding layer material is pulled from each other selected object's layer set. Falls back to the explicit prop if selection yields nothing.

Example 1 — simple materials: Select a concrete wall and a steel column, click "Select By Material" on either:

# Before
material = "Concrete"

# After
material = "Concrete" + material = "Steel"

Example 2 — layer sets: Select two walls, click "Select By Material" on Layer 1 (the exterior CMU layer). Wall A has [CMU, Air, GWB], Wall B has [Brick, Air, GWB]:

# Before
material = "IfcMaterialLayerSet"

# After
material = "CMU" + material = "Brick"

The layer index from the clicked material is used to look up the matching layer on every other selected object's layer set.

Clear hide_viewport and hide_set on matched objects
when the operator is invoked with Alt held, so hidden
objects of the target IFC class are revealed and selected.

Generated with the assistance of an AI coding tool.
ALT+Click now unhides hidden objects (viewport and local
hide) before selecting, matching the same behavior added
to select_ifc_class.

Generated with the assistance of an AI coding tool.
ALT+Click now unhides hidden objects (viewport and local
hide) before selecting, matching the behavior added to
select_ifc_class and select_similar.

Generated with the assistance of an AI coding tool.
ALT+Click now unhides hidden objects (viewport and local
hide) before selecting. Also fixes select_products to set
hide_viewport in addition to hide_set when unhiding.

Generated with the assistance of an AI coding tool.
ALT+Click now unhides hidden objects (viewport and local
hide) before selecting, matching the behavior added to
other select operators.

Generated with the assistance of an AI coding tool.
ALT+Click now unhides hidden objects (viewport and local
hide) before selecting, matching the behavior added to
other select operators.

Generated with the assistance of an AI coding tool.
Moves "select all listed elements" from ALT to SHIFT,
freeing ALT+Click to unhide hidden objects (viewport
and local hide) before selecting.

Generated with the assistance of an AI coding tool.
When mode is SHOW or ISOLATE, also unhide individual
objects (hide_viewport and hide_set) within each
container, not just the collection-level visibility.

Generated with the assistance of an AI coding tool.
- Add bim.select_similar_container button to the spatial
  decomposition panel, gated behind the new
  show_container_tools preference (renamed from
  container_hide_show_isolate)
- Fix select_similar_container to resolve container from
  the active list item rather than the active object
- Unhide individual objects when showing container
  visibility (set_container_visibility SHOW/ISOLATE)

Generated with the assistance of an AI coding tool.
@theoryshaw
Copy link
Copy Markdown
Member Author

theoryshaw commented Apr 16, 2026

Summary of rebase

  • Concatenate_selections is rebased onto Unhide_with_alt_click — same 5 commits, replayed cleanly on top
  • SelectSimilarContainer.execute(): supports both multi-container iteration (from Concatenate) and should_unhide (from Unhide), with the self.container panel shortcut preserved
  • SelectByMaterial.execute(): keeps Concatenate's full multi-object material loop, but now passes should_unhide=self.should_unhide to each core.select_by_material() call
  • Unhide_with_alt_click is untouched

The next build should merge both PRs in order — Unhide first (it's older, lower PR number), then Concatenate on top — with no conflicts.

When ALT is held, BIM_OT_select_aggregate now clears
hide_viewport and hide_set on matched objects before
selecting, consistent with the pattern used across other
selection operators on this branch.

Generated with the assistance of an AI coding tool.
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.
Previously the clipboard was set inside the class loop,
overwriting on each iteration and reporting multiple times.
Now all classes are joined with " + " and the clipboard is
set once after selection completes.

Generated with the assistance of an AI coding tool.
Previously only the active object's container was used.
Now all selected objects' containers are collected and their
decomposed elements selected, with the query copied to the
clipboard as location = "A" + location = "B".

Generated with the assistance of an AI coding tool.
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.
Previously only the explicit material prop was used. Now all
selected objects' materials are collected, with layer set usages
resolved to the specific layer index matching the clicked material.
Results are joined with " + " in the clipboard query.

Generated with the assistance of an AI coding tool.
@theoryshaw theoryshaw force-pushed the Concatenate_selections branch from 9de8661 to 7e3a9e4 Compare April 19, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant