-
-
Notifications
You must be signed in to change notification settings - Fork 405
Update pyrevitlib\pyrevit\revit\selection.py #2928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixed a bug where the revit.pick_linked() and revit.pick_linkeds() methods returned None due to incorrectly retrieving link instance elements.
There was a problem hiding this 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 fixes a bug where pick_linked() and pick_linkeds() methods returned None by adding logic to retrieve linked elements from RevitLinkInstance documents. The fix adds a conditional check to handle linked elements differently from regular elements, retrieving them from the linked document using GetLinkDocument() and LinkedElementId.
Review Summary:
The fix addresses the core issue but has critical gaps: it lacks an obj_type check (affecting pick_face()/pick_edge() behavior), missing null validation for unloaded links (causing crashes per Revit API defensive patterns in knowledge base), and redundant API calls (3x per reference). The suggested refactor uses an explicit loop with proper validation to handle linked elements safely while maintaining performance.
Follow-up suggestions:
|
Is devloai's code fix proposal automatically included in the PR or do I have to do it myself? |
Improved bug fix.
|
It is not. Like the copilot review when in launch them. |
|
I tested the code suggested by ai. It works. |
There was a problem hiding this 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 fixes a bug in the pick_linked() and pick_linkeds() methods where they were incorrectly attempting to retrieve linked elements using GetGeometryObjectFromReference() instead of properly accessing the linked document and element.
Key Changes:
- Fixed linked element retrieval by checking if the picked object is a
RevitLinkInstanceand usingGetLinkDocument()andLinkedElementIdto access the actual element in the linked document - Refactored the geometry object retrieval logic from a list comprehension to an explicit loop to accommodate the conditional handling
removed comment explaining change to previous code
|
📦 New work-in-progress (wip) builds are available for 5.3.1.25326+1040-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.25326+2050-wip |
Fixed a bug where the revit.pick_linked() and revit.pick_linkeds() methods returned None due to incorrectly retrieving link instance elements.
The remaining "pick_" and "get_picked_" methods were unaffected.