Add CAD-style cross selection as the default for Bonsai tools#8153
Open
theoryshaw wants to merge 2 commits into
Open
Add CAD-style cross selection as the default for Bonsai tools#8153theoryshaw wants to merge 2 commits into
theoryshaw wants to merge 2 commits into
Conversation
Introduce bim.cross_select, a Rhino/CAD-style box selection operator, and route every Bonsai workspace tool's selection through it. Dragging the box left-to-right selects only fully-enclosed elements (window); right-to-left selects anything the box touches (crossing). Works in Object and Edit Mesh modes; plain click, Shift (add) and Ctrl (subtract) behave as expected, and clicking empty space deselects. Selection logic is ported from the GPL-3.0 Blender-Cross-Select add-on (RARA, CYX, Witty.Ming, Shuimeng), reduced to box-only mode and adapted to read its colors and line width from Bonsai's add-on preferences. A new "Cross Select" add-on preference (CrossSelectPreferences) toggles the behavior. Because a WorkSpaceTool's bl_keymap is baked at import, the shared selection keymap is split into cross-select vs native variants and applied via apply_cross_select_preference(), which rebuilds each tool's keymap and re-registers all selection tools in place. Toggling the preference re-applies live via a deferred timer, and the saved preference is applied on startup. When disabled, tools fall back to Blender's native view3d.select_box / view3d.select. - tool/blender.py: split native/cross-select keymaps, pref-driven get_default_selection_keypmap, apply_cross_select_preference re-registration - bim/module/model/workspace.py: bim.cross_select operator and geometry/draw helpers - bim/ui.py: CrossSelectPreferences group, preferences UI, live-toggle callback - bim/__init__.py: register preference group, apply saved preference on startup - bim/module/model/__init__.py: register CrossSelect operator Generated with the assistance of an AI coding tool.
…NG modal Blender fires all matching tool-keymap entries' invoke() even after an earlier entry returned RUNNING_MODAL. When cross-select is enabled, bim.cross_select (bl_options BLOCKING) goes modal on every LMB press alongside bim.click_nearest_dimension_anchor. Its BLOCKING flag causes it to win the RELEASE event, selecting the background object instead of activating the anchor dot. Fix: CrossSelect.invoke() now calls _near_dimension_dot() before going modal. If a parametric dimension anchor dot is within 15 px of the cursor it returns PASS_THROUGH, yielding to ClickNearestDimensionAnchor. Also fixes apply_cross_select_preference to preserve pre-selection entries (e.g. ClickNearestDimensionAnchor) when rebuilding tool keymaps: replaces _tool_extra_keymap (which assumed the selection block starts at index 0) with _split_tool_keymap, which searches for the selection block by operator name and returns (pre, post) slices independently. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce bim.cross_select, a Rhino/CAD-style box selection operator, and route every Bonsai workspace tool's selection through it. Dragging the box left-to-right selects only fully-enclosed elements (window); right-to-left selects anything the box touches (crossing). Works in Object and Edit Mesh modes; plain click, Shift (add) and Ctrl (subtract) behave as expected, and clicking empty space deselects.
Selection logic is ported from the GPL-3.0 Blender-Cross-Select add-on (RARA, CYX, Witty.Ming, Shuimeng), reduced to box-only mode and adapted to read its colors and line width from Bonsai's add-on preferences.
A new "Cross Select" add-on preference (CrossSelectPreferences) toggles the behavior. Because a WorkSpaceTool's bl_keymap is baked at import, the shared selection keymap is split into cross-select vs native variants and applied via apply_cross_select_preference(), which rebuilds each tool's keymap and re-registers all selection tools in place. Toggling the preference re-applies live via a deferred timer, and the saved preference is applied on startup. When disabled, tools fall back to Blender's native view3d.select_box / view3d.select.
Generated with the assistance of an AI coding tool.