LearnRevitAPI

Dec 4, 2022


Reading and changing parameters is the whole premise of Revit, because that's where the data lives and it controls everything. So it's crucial to understand How To Read and Set New Values 

Parameter Types

There are 5 different parameter types, 
but I will cover the first 3.

🔹Built-In Parameter
🔹Project Parameter
🔹Shared Parameter
🔸Global Parameter
🔸Family Parameter

How to Get Parameters?

Project and Shared parameters are quite easy to work with, we can get them with their Name, since it will not change in different Revit Languges. 

However, Built-In parameters can change display names. Therefore they have unique internal name assigned to them, e.g.

InternalName:
BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS

DisplayName:
English: Comments
German: Kommentar

You can use Revit LookUp to look inside parameters to find Internal Name. The property is located in Parameter.Definition.BuiltInParameter

It's possible to get Built-In Param by name, but your script will crash in other Revit Languages, therefore we need to use internal name whenever we deal with Built-In Parameters

Let's look at different methods to get Parameters

Built-In Parameter

.get_Parameter(BuiltInParameter)

If you setup Revit API Autocopmlete, then it's quite easy. Once you put a dot after BuiltInParameter it will suggest you Internal names.

Project/Shared Parameter

.LookupParameter('Param')

This method is straight-forward. Just write name of your parameter and it will try to get it. But make sure it exists in the project and you spell it correctly!

How to Get Paramter Value?

🔸 Methods

There are different methods to get different values based on Data Type.
You can always have a look inside parameters with Revit Lookup to be sure which one to use

As you can see in the screenshot I know that .AsString() is  going to return 'Special Wall'

How to Set Parameters?

To set a parameter, first of all we need to get it and then we can use .Set() method and provide the right value. 

And since we are modifying the project, we need to create a Transaction(I will have separate email about them)

👇 Have a look at the example below

P.S. It will not do anything if you are trying to set the wrong Data Type. 

If you will try to set a number to a Text Parameter it will not give you an error, but it won't do anything. And it can drive you crazy that nothing is happening. 

😅I speak from experience...

Here is an example

💪 Give it a try yourself! 

Open RevitPythonShell and write this,
it will get more clear what is going on. 

✅ Try Getting a few BuiltInParameters. Read and Set values.
✅ Do the same with Project/Shared Parameters 

⌨️ More Examples

I have prepared a python file with more examples on Getting and Setting parameters. Have a look, it's easier to understand when you see an example.

👉GitHub Link



🎦 Video Tutorial

Dive deeper with my Tutorial on Revit API Parameters
👇

How to Get/Set Parameters with Revit API

Learn how to use parameters with Revit API.
👀 Watch it

Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 6700+ people!