View.AddFilter for multiple views

Hi everyone,

I have a script ready to add view filters to view templates. It only works on a single view template. I would like to change this so that a view filter can be added to multiple view templates at once.
However, the node view.addfilter only accepts one view. Does anyone have an idea for this? maybe there is a node in another custom package?

Thanks in advance for thinking along!

Hi @Reinier

You can add a list of views to the View.AddFilter. Dynamo will automatically use the Function for all the views in the list.

You do need to think about the levels in the Node. If you provide a list with 5 views and 5 filters, dynamo will add filter 1 to view 1 and filter 2 to view 2.

If you set the level for Views to @2 and the level for Filters to @1, Dynamo will add all the filters from the filter list to all the views.

Nice! It works, thanks!

This will be so helpful! For clarity, what are the code blocks referring to in the ‘which filter’ group? I’ve just tried running with the first showing “ParameterFilterElement” and the second as my filter name, but am getting an error. And not sure where the levels should be adjusted…? I appreciate the help!

I thought I had solved this the other day, but it turns out it’s still not quite working. @Joelmick, is there anything to update now for Revit 2021+ where Filters can be both ‘Enabled’ and ‘Visible’? The goal on my side is to 1) add the filter to all plan view templates and 2) turn off the visibility. Your advice is most welcome! :slight_smile:

Hi Ashley, try to use “IN output” from list.filter by Boolean mask and you can check the lacing for view.add filter.

Hi Aravind – apologies, I had updated those things, here’s the latest:

it look like you used the same code blocks. if i use a custom package, you can see in the script wich version i used. mine works fine in revit 2020, mayby newer version its not working? did you get it ready yet?

Thank you, @Reinier – yes, everything seems to be the same, and it doesn’t give me any errors when I run it (just says ‘Run completed’). I think the difference is to do with 2021 and the added need to select both ‘Enable Filter’ and ‘Visibility’ here:


Could this be an override written into a code block? Replacing the overrides node? Just not sure how to both add and affect the ‘visibility’ side of it.

This should help:

1 Like

Hi Reinier,
Is this available for download?