LearnRevitAPI

🤔 Check if Shared Parameters Loaded with Revit API

Dec 3, 2024

Is Parameter Loaded?

Whenever you create a custom tools, you often need to work with your shared parameters. And before you do anything with it, you better ensure that you have your parameters loaded to avoid crashing.Here is how to do that.

How to read Project Parameters?

We need to get that list of loaded parameters inside the project and check if out parameter names are included or not.

We need to get Parameter Bindings Map in Revit API with this code:

Keep in mind, that it's a bit tricky to work with, because you need to use ForwardIterator to get items from it. You can't treat it like a regular list or other containers.

Forward Iterator

A ForwardIterator in the Revit API is like a one-way list reader. It lets you go through items in a collection one at a time, starting from the first item and moving forward, but you can't go backward or skip around.

It's used in API to be as efficient as possible in terms of memory handling.

Here is a code example of how to get ForwardIterator and grab all parameter definitions and read their names.

Keep in mind that you get Definitions

  • A Parameter Definition describes the parameter's rules and structure, like its name ("Height"), type (Length), and other things... It's the template used by elements.

  • A Parameter is what every element have based on the definition and it can have different values across all elements.

Check if Parameter Loaded

Lastly, once you have a list of loaded parameter names, it's quick and easy to check what is loaded or not.

Here is how

Final Snippet

In conclusion, let's put it all together in a single snippet.

I know that it looks confusing to use ForwardIterators, but you can just copy this code and make a function out of it.

Want more?

Let me know if you want to learn more about Shared Parameters in Revit API and what exactly you want to learn.

Hit 'Reply' to share ideas.

Testimonial of the Week

I love getting feedback from my audience and students. Here is the recent one that made my day!

You can share testimonials here

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 7500+ people!