LearnRevitAPI

⚙️How to modify Shared Parameters with Revit API and Python?

Mar 4, 2025
⚙️Modify Shared Parameters

Managing Shared Parameters is Slow and Boring...
But as pyRevit developers we can define the logic for managing parameters once, and then reuse it across all projects. And the more parameters you have, the more you need to automate how you manage them.
And that leads me to today's question I got:
"How to modify Categories in existing SharedParameters"?
Let me share the answer:
#1 - Define Categories
Firstly, let's create a list of BuiltInCategories that we want to include in Shared Parameters.

P.S.
We could also override or use different logic for setting categories. I just keep it simple to follow along.
#2 - Get Shared Parameters
Now, we need to get existing parameters from Revit project. Manually you would normally open Project Parameters menu:

But, in Revit API it's called BindingsMap, and we can get it with doc.ParameterBindings property.
Then we can iterate through the list, but it will be a little tricky because we need to use ForwardIterator. It's a weird concept to grasp, because it doesn't allow to iterate with a for-loop, but instead, requires you to use: .MoveNext() and .Current...
Here is a code snippet to iterate through BindingsMap and save all definitions in a dictionary as {definition:binding}.

#3 - Modify CategorySet and ReInsert
Lastly, we can iterate through parameter definitions, and modify their current binding settings. During this step we also need to make sure that we have some logic on selecting parameters, so we don't modify all of them.
Let me provide you a code snippet and then I explain what's going on:

⌨️Code Breakdown:
Start Transaction to allow changes with RevitAPI
Iterate through dict_parameters {def : binding}
Ensure Definition.Name includes 'EF_'
Get current CategorySet
Iterate through extra_categories and add if necessary
If new category was added, then update parameter using BindingsMap.ReInsert method.
Report on changes
💡And that's how you modify CategorySet of your parameters.
P.S. Definition - is like a template for your parameters. It's where all the settings and controls are located.
Final Code
Finally, let's put it all together into a single snippet you can take and adjust to your own needs.
Here is the code:

P.S.
If you want to learn more about Shared Parameters and many other Revit API Topics, then Click Here to learn more.
Join Newsletter
📩 You will be added to Revit API Newsletter
Join Us!
which is already read by 9500+ people!




