Skip to content

fix invalid element id value handling#2900

Merged
jmcouffin merged 2 commits intopyrevitlabs:developfrom
thumDer:id-fix
Nov 3, 2025
Merged

fix invalid element id value handling#2900
jmcouffin merged 2 commits intopyrevitlabs:developfrom
thumDer:id-fix

Conversation

@thumDer
Copy link
Copy Markdown
Contributor

@thumDer thumDer commented Nov 3, 2025

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:

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

Thank you for contributing to pyRevit! 🎉

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:

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.

@jmcouffin jmcouffin merged commit 48562f6 into pyrevitlabs:develop Nov 3, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 3, 2025

📦 New work-in-progress (wip) builds are available for 5.3.0.25307+2237-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 4, 2025

📦 New work-in-progress (wip) builds are available for 5.3.0.25308+0721-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 4, 2025

📦 New public release are available for 5.3.0.25307+2146

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants