Skip to content

Feature 2248 - Toggle Grid Bubbles By Direction#2738

Merged
jmcouffin merged 12 commits intopyrevitlabs:developfrom
MohamedAsli:feature-2248
Aug 1, 2025
Merged

Feature 2248 - Toggle Grid Bubbles By Direction#2738
jmcouffin merged 12 commits intopyrevitlabs:developfrom
MohamedAsli:feature-2248

Conversation

@MohamedAsli
Copy link
Copy Markdown
Contributor

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.

ToggleGrids

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:

  • Code follows the PEP 8 style guide.
  • Code has been formatted with Black using the command:
  • Changes are tested and verified to work as expected.

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 !

Copy link
Copy Markdown
Contributor

@devloai devloai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • @devloai fix the null reference issues in the bounding box handling methods
  • @devloai consider adding error handling for edge cases like curved or multi-segment grids

@jmcouffin jmcouffin requested a review from Copilot July 30, 2025 09:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jmcouffin
Copy link
Copy Markdown
Contributor

@MohamedAsli Nice tool!
and great PR.

Please implement the review by our AI friends whenever it makes sense; I will test it afterwards.

@jmcouffin jmcouffin added New Feature New feature request [class->Implemented #{number}: {title}] Tools Issues related to pyRevit commands [subsystem] labels Jul 30, 2025
…ary view mode is enabled and handle NoneType exception that may be raised with the boundingbox.Enabled property
@MohamedAsli
Copy link
Copy Markdown
Contributor Author

MohamedAsli commented Jul 30, 2025

Added bundle informations.
Handled the NoneType thing (which wasn't a real issue, as I prevented script to run with grids hidden, so never caught a NoneType while getting the boundingbox). But now the script runs even if grids are hidden. They are simply skipped.
I consider if they are temporarily or permanently hidden, the user doesn't mind whether bubbles are hidden or not (I may be wrong in some cases)

@jmcouffin jmcouffin merged commit e7b9644 into pyrevitlabs:develop Aug 1, 2025
@jmcouffin
Copy link
Copy Markdown
Contributor

Great Job @MohamedAsli !

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 1, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25213+1402-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1027-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1429-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+0909-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1354-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1400-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1405-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 2, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25245+1846-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 3, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25246+0855-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25248+0948-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 8, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0758-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 8, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0805-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 8, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0824-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 9, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25252+1659-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0644-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0911-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25256+0727-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25258+1448-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25265+1047-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25266+0803-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25268+1757-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1336-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1431-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1436-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1822-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25271+1719-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2003-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2012-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2017-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2149-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 1, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25274+1734-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1425-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1427-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 6, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25279+2157-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25280+0218-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25302+0949-wip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Feature New feature request [class->Implemented #{number}: {title}] Tools Issues related to pyRevit commands [subsystem]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants