Feature 2248 - Toggle Grid Bubbles By Direction#2738
Feature 2248 - Toggle Grid Bubbles By Direction#2738jmcouffin merged 12 commits intopyrevitlabs:developfrom
Conversation
There was a problem hiding this comment.
PR Summary:
This PR introduces a new "Toggle Grid Bubbles by Direction" command that enhances the existing grid bubble management functionality. It allows users to selectively toggle grid bubbles based on directional orientation (top, bottom, left, right) using a WPF dialog interface. The implementation uses grid bounding boxes to determine directional positioning and supports both selected grids and all visible grids in the active view.
Review Summary:
The core functionality is well-designed with good separation of concerns between the CustomGrids class and ToggleGridWindow UI. However, there are critical null reference vulnerabilities in the bounding box handling logic that need immediate attention. The code follows pyRevit patterns for transactions and event handling, but lacks proper defensive programming for API calls that can return null values.
Follow-up suggestions:
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Outdated
Show resolved
Hide resolved
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Show resolved
Hide resolved
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Show resolved
Hide resolved
...Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/bundle.yaml
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new command "Toggle Grid Bubbles by Direction" that enhances the existing grid bubble functionality by allowing users to selectively toggle grid bubbles based on their directional orientation (top, bottom, left, right). The feature provides a more granular approach compared to the existing "Toggle All Grid Bubbles in Current View" command.
Key changes:
- Implements directional grid bubble toggling with UI controls for each direction
- Adds logic to determine grid orientation and bubble positioning using bounding box calculations
- Provides real-time UI updates with checkbox and radio button synchronization
Reviewed Changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| bundle.yaml | Adds the new command to the Views pulldown menu with separators |
| ui.xaml | Creates the WPF interface with directional checkboxes and toggle controls |
| script.py | Implements the core logic for grid analysis, bubble management, and UI handling |
| bundle.yaml (pushbutton) | Defines tooltip localization and engine configuration |
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Outdated
Show resolved
Hide resolved
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Show resolved
Hide resolved
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Show resolved
Hide resolved
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Show resolved
Hide resolved
...g Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/script.py
Show resolved
Hide resolved
|
@MohamedAsli Nice tool! Please implement the review by our AI friends whenever it makes sense; I will test it afterwards. |
…ary view mode is enabled and handle NoneType exception that may be raised with the boundingbox.Enabled property
|
Added bundle informations. |
...Set.panel/views.stack/Views.pulldown/Toggle Grid Bubbles by Direction.pushbutton/bundle.yaml
Show resolved
Hide resolved
|
Great Job @MohamedAsli ! |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25213+1402-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1027-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1429-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+0909-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1354-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1400-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1405-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25245+1846-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25246+0855-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25248+0948-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0758-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0805-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0824-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25252+1659-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0644-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0911-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25256+0727-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25258+1448-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25265+1047-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25266+0803-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25268+1757-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1336-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1431-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1436-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1822-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25271+1719-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2003-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2012-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2017-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2149-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25274+1734-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1425-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1427-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25279+2157-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25280+0218-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25302+0949-wip |
Toggle Grid Bubbles by Direction Command
Description
This PR adds a command that replaces the existing "Toggle All Grid Bubbles in Current View".
It allows users to toggle all bubbles in the active view but also implements the logic to toggle by direction.
It uses two main classes to manage grids and the UI window.
Directionality is not directly accessible in the API, so I used the distance from the grid bounding box corners to determine the right/left and top/bottom bubbles, and also check if the grid is horizontal, vertical, and so on.
The current script successfully toggles vertical and horizontal grids that are aligned with the internal origin orientation, both in plan/ceiling and section/elevation views (3D intentionally discarded). The next step is to manage project north (if it exists) to consider grids in the rotated coordinate system rather than the internal origin system.
I managed the visibility toggles with events, to instantly see effects on the view (was a bit inspired by @thumDer and his 'show view range').
Can run on a selection of grids, if no selection collects all grids in active view.
You will understand the next sentence once you test the command :
I've tried to keep checkboxes and radiobuttons in the UI updated to match the view and vice versa. But I detected one side effect to this functionality > once we we check/uncheck all checkboxes, radiobuttons update and effectively toggle visibility of all bubbles, even those not initially handled (diagonal ones).
Need your feedback and comments!
Checklist
Before submitting your pull request, ensure the following requirements are met:
Related Issues
#2248
Additional Notes
I made this back in June 2024 but did not have the time to push it.
I developed it in another repo back then, so the first commit brings a lot, sorry !