Turn a filter on or off in a view template without overriding graphic settings

Hello everyone,
I have been trying to set up a Dynamo script to turn on/off filters for multiple view templates at once. The only node I found that is able to do this is the View.SetFilterOverrides node. I could not find anything similar in any other packages.
The problem with this node is that i needs a graphic override input. With that, all the pre-set filter overrides get deleted. Is there a way to turn off a filter for a view template without overriding the graphic settings that has been defined in revit before hand?
image

@gairikb1026 ,

so you want just set Viewfilters ?

grafik

KR

Andreas

Hello @gairikb1026 and welcome here :wink: try something here…
Revit_RGxrONQ2WV
filter visibility.dyn (12.8 KB)

3 Likes

PS that exemple is for visibility filter…if you are after enable filter on/off then Rhythm have a node for that

Capture

Thanks a lot! I will try this out. Exactly what I have been trying to do. Wanted to find a node for it first to avoid a Python script.

1 Like

Think you can find some in many package…i know Zhukoven package have one

1 Like

Hi Andreas, this node just returns if a particular view has any view filters in it. Not what I was looking for. I want to make an existing filter invisible/visible in multiple views.

This is perfect. Thanks a lot @sovitek

1 Like

Hello Sovitek which Node controls the Enable Filter?

Hi @nigelx.casey as mention in thread i guess Rhythm have one for enable filter or try here

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

view = UnwrapElement(IN[0])
filter_elements = UnwrapElement(IN[1])
visibility = IN[2]

result = []
count = 0

if not isinstance(filter_elements, list):
    filter_elements = [filter_elements]

if not isinstance(visibility, list):
    visibility = [visibility]

if filter_elements and visibility:
    TransactionManager.Instance.EnsureInTransaction(doc)
    while count < len(visibility):
        for f in filter_elements:
            try:
                view.SetIsFilterEnabled(f.Id, visibility[count])
                result.append(view)
                count += 1
            except:
                prev_state = visibility[count-1] if count > 0 else False
                view.SetIsFilterEnabled(f.Id, prev_state)
                result.append(view)
    TransactionManager.Instance.TransactionTaskDone()
else:
    result = "Error: filter_elements or visibility is not valid"

OUT = result

1 Like