LearnRevitAPI

🔽 How to Copy View Filters with Revit API in Just 3 Steps...

Feb 18, 2025

Copy View Filters

I just got a question: "How to copy view filters between views?"

It's actually very easy to copy filters. You need to get a view, read its filters, get overrides and you are ready to create the same filters. However, the simplest step can also be the trickiest of them all if you don't pay attention.

So, let me show you how to do it right.

And if you have other API questions,
you know where the ➡️Reply Button is.

Now, are you ready to copy views?

1 - Get Views

Firstly, let's get some views.

I will keep it simple and get views by name from a collection. However, keep in mind that you might need to filter a few things out to get the right views. I will do the following:

  • Filter Views by ViewType (because we can have same view names across different types)

  • Filter ViewTemplates out.

  • * Filter Views without Filters (Optionally if you want users to select view_from, I will skip this.)

So here is the simple snippet to get views by name:

💡You can make it more efficient by keeping collector outside, but I keep it simple for tutorial.

2 - Get View Filters

Once we have the view, we need to select some filters.

I don't always want to copy all available filters, so we will use a simple pyrevit.form - SelectFromList, so user can decide what they want to copy.

Here is the code snippet:

  • GetOrderedFilters()

  • Convert ElementIds to Filters

  • Create SelectFromList form

  • Ensure Filters selected

3 - Copy View Filters

Alright, it's time to do the magic.

To copy filters from view A to B we will need to read a few settings so we can set the same overrides and visibility controls.

Here is the code snippets for that:

  • 🔓 Use Transaction to make changes

  • For Each Filter:

    • Get Filter Overrides

    • Set Filter Overrides (it will also create it)

    • Get Filter Visibility

    • Get IsFilterEnabled

    • Set these settings to new filter

And that should copy your view filters.

Result

Here is the proof that it works:


Now you can take this snippet and extend it to copy many filters from many views in your project.

Just think of logical steps you need for your unique workflow.

Happy Coding.

P.S.

I love when python code looks just like English.

Scroll through code snippets again and just read them as English, and it might surprise some of you, but python and API can be very easy to read too.

Sometimes we just need to know the right words, and then coding becomes easy. If you need help to learn these right words: 👉Click Here to learn more.

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