fix invalid element id value handling#2900
Conversation
There was a problem hiding this comment.
PR Summary:
Fixes type mismatch issue for InvalidElementId value handling in WPF data binding. Previously hardcoded -1 (int) caused binding failures in Revit 2024+ where ElementId values are long type. The fix introduces INVALID_ID_VALUE constant derived from get_elementid_value(DB.ElementId.InvalidElementId) to ensure correct type consistency across all Revit versions.
Review Summary:
Thoroughly reviewed the changes - no issues found. The implementation correctly addresses the int/long type mismatch across Revit API versions (≤2023 uses IntegerValue:int, ≥2024 uses Value:long). All 11 occurrences of hardcoded -1 properly replaced with the module-level constant. Code follows PEP 8, Black formatting standards, and is compatible with IronPython 2.7.12. The solution also improves performance by calling get_elementid_value_func() once instead of repeatedly.
Review utilized knowledge of: pyRevit compat module patterns, Revit API version compatibility, and IronPython development standards.
Follow-up suggestions:
N/A - PR is ready to merge as-is.
|
📦 New work-in-progress (wip) builds are available for 5.3.0.25307+2237-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.0.25308+0721-wip |
|
📦 New public release are available for 5.3.0.25307+2146 |
fix invalid element id value handling
Description
ElementId value extraction was handled in all cases except for
InvalidElementId, which was always -1 -> int, which caused datatype mismatch in the binding of level comboboxes (long vs int)Checklist
Before submitting your pull request, ensure the following requirements are met:
pipenv run black {source_file_or_directory}Thank you for contributing to pyRevit! 🎉