Resources
Downloads
Summary
Parameters in Revit API
Let's have an overview of Parameters in Revit API.
There are 5 different types of parameters:
Built-In Parameters
Shared Parameters
Project Parameters
Global Parameters
Family Parameters
Let's focus on the first 3 types of the parameters and they also share the same Parameter Class in Revit API.
Parameters Overview in Revit API
Let's have an overview of Parameters in Revit API.
We can explore them inside of Revit Lookup to see actual values returned by different properties.
👉 Select an Element(Wall) -> Revit Lookup -> Snoop Selected -> Parameters
You will see a menu with a list of parameters on the left and properties and methods of selected parameter on the right.
By exploring this menu we can learn everything we need to know about our parameters and understand how to get them in the code.
This property will return you InternalDefinition of the Parameter. This class has the following useful properties:
Name
ParameterGroup
BuiltInParameter
VariesAcrossGroups
StorageType
StorageType is an Enumeration, so we can have a look inside of Revit API Docs, and see all possible values. Here are all possible StorageType values👇.
But wait, I thought Revit has far more Data Types? Not Exactly.
It's True that Revit has many Types for our Parameters.
But it only uses 4 in Revit API for all these parameters.
All these parameter types use one of the following StorageType in Revit API:
Double
ElementId
Integer
String
Even types like Yes/No parameter.
Obviously it's a Boolean parameter, but Revit API uses Integer to define values (0 = No, 1 = Yes).
Type Parameters
❌ Also some of you will try to get Type parameters from instance elements, and that won't work!
Element and ElementType are 2 different objects in Revit API ! Surely, they are related to one another, but you need to be aware what you are working with.
So if you want to get a type parameter, you would need to get Type object first, and then use the same methods to get a type parameter.
👇 Here is an example of getting Instance and Type Parameters
Read parameters with python
Let's apply all this theory.
I am going to write a code snippet that will iterate through all the instance parameters and we will get different properties and methods.
💡 You wouldn't do that in your scripts, but I think it's good to do it once to understand what and how we can get out of the parameters.
This Snippet will let you pick an element and then iterate through all available parameters and print properties that we selected.
Also notice that I created a function get_param_value(p) to get parameter values based on their StorageType and AsValueString(), so you will be able to compare values that you get.
👀 Here is the result that this snippet will show in the console.
HomeWork
❗Try to use the code snippet to read parameter properties of different Category.
💼 Also try to modify this snippet to read all Type parameters.
👆 You have a snippet written in the post above on how to get type parameters!
⌨️ Happy Coding!