Create and add view filter (ParameterFilterElement)

Hi, I search for something like SelectionSet.ByElements (Clockwork). But instead of selection-based filters I want to create rule-based filters.

I found this:

So it should work with Dynamo and Python - ParameterFilterElement.Create and View.AddFilter - , right?

Can anyone help me with this? Thanks.

Let me get this right. You want to add View Filters to a View using Dynamo. What filter exactly are you interested in? Can you post a specific example, maybe a screenshot that has the rules in it. This information would really help us narrow down all of the possibilities.


Hi Konrad,

basically I want to create these filters (picture below)… The goal is to create all the filters from excel or with if/then logic in dynamo. For example, if there is walls with values in parameter “Comments” then create a filter for each value. Next stept is to add all the new filters to a view (maybe first create a new view for it).

First step would be to create a new filter.


  • Name (Filter Name)
  • Category/Categories
  • Parameter Name
  • Rule
  • Parameter Value
Second, add filters to view:


  • View(s)
  • Filter Name
  • Visibility
  • Lines
  • Patterns
  • Transparency
Hope it's a bit clearer now. Thank you! ![Filters|736x599](upload://d9MO2Q77glIjnH5mgVvEL21n6O8.jpg)

Ok, now we are getting somewhere. Showing clearly what you need is step one. Step two is to show some work that you have done. This forum is not exactly a place where you just post “tell me how to do this because i need this for my homework/work, and send the ready definition to my email”. It’s a community support forum and we (at least I do) have some rules that we follow.


  1. Post clear description of problem. Images, sample files are welcome. Please only post minimum required to duplicate the issue.

  2. Show some work that you have done and got stuck on. Post with no work shown, and flat out asking for handouts are going to get ignored (by me).

Again, this is a support forum. These rules are not so different than what you see here: Grasshopper Forum or at StackOverflow Forum


I totally understand you and that was definitely not what I intended. Sorry!

I tried to take the idea from the link and put it in a python script. Sorry, I’m at the very beginning with this. Maybe I should have started with something easier…
But here is what I have so far. It seems to work until the filter. (If I delete the row #35 and say “OUT = rules” I get an output…)

So, I would be very thankful if you could help me with this: filter = ParameterFilterElement.Create(doc, ‘Test’, categories, rules)
I don’t see what is missing, or is it a wrong code?

import clr

from Autodesk.Revit.DB import *
from System.Collections.Generic import *

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
view = doc.ActiveView

#name = IN[0]
#category = IN[1]
#parametername = IN[2]
#parameterrule = IN[3]
#parametervalue = IN[4]

categories =

collector = FilteredElementCollector(doc)
wallWidth = collector.OfClass(WallType).FirstElement().get_Parameter(BuiltInParameter.WALL_ATTR_WIDTH_PARAM)

rules =
rules.Add(ParameterFilterRuleFactory.CreateLessRule(wallWidth.Id, 0.5, 0.001))


#filter = ParameterFilterElement.Create(doc, ‘Test’, categories, rules);

OUT = rules



This is good. You are missing a few things like:

  1. You need to enclose modifications to revit model in transaction calls. revit won’t allow you to modify its database without starting a new transaction unless there is one already open.

  2. You have to then close the transaction for the changes to be permanent, otherwise they will not be commited/visible.

  3. You declared rules to be a list by calling rules=. In python you don’t add elements to a list. You can append/extend instead.

  4. To make a proper call to ParameterFilterElement.Crete() you need a typed list of element ids for the category input. that’s something different than a list in python so we need to import a module called System.Collections.Generic and convert from list to typed list.

  5. Now, both of the calls ParameterFilterElement.Create() and view.AddFilter() will throw an exception if you are trying to create a filter with a name that already exists or trying to add a filter to a view with a name that already has one. to work around that i just put those in a try/except statement but truth is that you would be best served to have a method in place that checks if given filter exists and overrides its properties instead. That’s for another day though.

Please have a look at this:


and this:


Finally the code:


The custom node used to extract parameter names from the Wall can be found in archi-lab package.

Good luck!

1 Like

this was pretty cool exercise. Python node was much faster to put together, but I was also able to build a better workflow I think with the Zero Touch nodes. All I need now, is to add bunch of different rules and this will be a pretty good set of tools for controlling view filters. This is just beta so I am not going to share just yet, but that’s the goal:


I have a similar but hopefully simpler task.

I want to duplicate a filter and change the value of the parameter it filters by.

It that possible?


i imagine that would be possible. forum etiquette requires that you start a new thread instead of hijacking this one. please do so.


Konrad, thank you very much. I appreciate it a lot!

I’ve tested your script. Unfortunately I get this Error…
Without line 45 and 47 it works. I get the filter (without rule but with name and categories) in the view.
I have to spend more time on understanding everything, the variables and definitions, in the script.

Now I wanted to add the graphic settings, especially projection/surface patterns.
It works for “SetCutLineColor”, “SetCutLineWeight” and “SetProjectionFillPatternColor”.
But I think there is a problem with the “SetProjectionFillPatternId”.
The value for the ID should be “1” for example? I also tried your “Pattern Types” node (Bumblebee) as Input.

Thanks and best regards, Dennis



With “SetProjectionFillPatternId(ElementId(1))” it does something. So I don’t get an error and in the pattern field it’s not “” anymore. pattern

I am sorry for posting an image of code, but it seems that you have made an error typing it up. Can you check again all of the lines, and make sure that you didn’t misspell anything. I think there is no GetBuiltInParameter anywhere in my code, so I am not sure how it got into yours.

I would post code here for you to just copy paste, but I hate how code formatting/posting is handled on this forum. They need to fix this thing. It’s outrageous.

Ps. I will be looking more at this whole workflow for a different project that I am working on so I will send you something, but I am a little busy today so I don’t know when it will happen. Keep diggin.

Yes, there was something wrong because of trying to many different spellings. This is the actual error:


I’ve added a new input with a list of names for the filters (strings). So at the end I want to create a filter for the combination of many (specific) filters and their values.

e.g. “RoomName_Kitchen” ; “RoomName_LivingRoom” … Think I’ll need a lot more time for that. Thanks for your effort!


so this was set up to work with a BuiltInParameter and not a Shared Parameter. I was just trying to show you the general idea. The built in parameter in Revit is the one that has all caps names like this: ROOM_NAME, ROOM_NUMBER, TEXT_TEXT etc. They are parameters that are hard coded into Revit. If you want to use the Shared Parameter you would need to change a few things to handle that.

At the moment I also run it with the BuiltIn and your Get_BuiltInParameter_Name node.

Regarding to the problem with SetProjectionFillPatternId(ElementId(1)) … Is there a simple solution?

Had not much time to dynamo around but at least I could solve the problem with FillPatternId…

fillPattern = UnwrapElement(IN[5])

I’d like to ask how to set rule for duct system type parameter.

For example parameter: RBS_SYSTEM_NAME_PARAM works, but RBS_DUCT_SYSTEM_TYPE_PARAM doesn’t (see attached drawing).
Any hint what am I doing wrong?

rules.append(ParameterFilterRuleFactory.CreateEqualsRule(ElementId(bip), pValue, True)) - (Id, string, bool)
bip = GetBuiltInParam(paramName) - definition by Konrad

Maybe I need to delete and recreate mep system type?

Thank you





@Tomasz_Puchala please start a new thread for this question. The original question was already answered and this whole thread is getting a little incomprehensible with all the tangents that people take it to. Thanks!

A post was split to a new topic: Parameter Filter Element