Skip to content

Extend parameter lookup helpers (query.py)#3298

Open
Wurschdhaud wants to merge 2 commits intopyrevitlabs:developfrom
Wurschdhaud:improve-get_param
Open

Extend parameter lookup helpers (query.py)#3298
Wurschdhaud wants to merge 2 commits intopyrevitlabs:developfrom
Wurschdhaud:improve-get_param

Conversation

@Wurschdhaud
Copy link
Copy Markdown
Contributor

@Wurschdhaud Wurschdhaud commented Apr 12, 2026

Description

get_param previously only accepted a string name, routing everything through LookupParameter — which the Revit docs flag as ambiguous and non-portable. This PR broadens the API and consolidates the scattered safe_get_parameter helper into it.

What changed

  • get_param now dispatches on identifier type: str (original behaviour), DB.BuiltInParameter, System.Guid, and DB.ElementId
  • DB.ElementId resolution prefers GUID lookup, falls back to Definition, matching what safe_get_parameter did
  • safe_get_parameter can be removed — all call sites migrate to get_param(elem, param_id) with no other changes

Backwards compatibility

Fully backwards compatible. get_param(element, "some name") behaves identically to before.

Why LookupParameter on strings is kept but not extended

It remains the right tool when you're confident a name is unique. get_params is the documented safer path when that assumption doesn't hold.


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.

@devloai
Copy link
Copy Markdown
Contributor

devloai bot commented Apr 12, 2026

Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

@Wurschdhaud Wurschdhaud changed the title Extend parameter lookup helpers (query/parameters.py) Extend parameter lookup helpers (query.py) Apr 12, 2026
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

3 participants