Sep 30, 2022
Revit API: Get Elements or Types by Type/Family name
Here you will learn about getting Elements,Type or Family by providing a Type or Family Name.
Finally functions to get you what you want!
If you are a Revit API enthusiast, then at certain point you wanted to get your elements or types just by writing Type or Family name as a string. It sounds like a very logical thing that should be within Revit API, but it's not.
So let me help you with that! Below you will find snippets and a brief explanation on how to make a function to do that using ElementParameterFilter Class.
Get Element of a certain Type Name
We will use ElementParameterFilter to create a function to get elements by Type Names.
Parameter Id to create ParameterValueProvider
Evaluator (FilterStringEquals) in this case
Also notice that there were changes in Revit API for this class so I will account for that too
Then we can provide all of this to create ElementParameterFiler
Get Elements with Family Name
We can also modify very little a get elements by Family name instead of type.
To do that we need to
- Change Parameter Id to BuiltInParameter.ALL_MODEL_FAMILY_NAME
- Rename function and variables
The rest stays the same, here is complete Snippet.
Get Types by Type or Family Name
You might also want to get types instead of instances and you can use exact duplicates of these functions but replace
Here is an example:
These are really good examples on how to use ElementParameterFilter. You can adjust very little and it will work with other parameters, and evaluators.
There will be a post about it in more detail in the future 😉