Turn off the visibility of a View Filter


#1

Hi all,
I would like to create a filter, assign it to a view and turn its visibility off.
I already found how to create the filter and assign it to a view. It is also solved how to change its graphic override, but I could not find a way to turn its visibility off.
Does anyone know a solution for that?

This is the custom node that I use:

This is what I got from this topic “Create and add view filter (ParameterFilterElement)”:

The problem is in Line 53. It does not give a warning, but definitely does not turn the visibility off. What can be the problem?

Here is the code for copy/paste:
import clr

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

doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *

dataEnteringNode = IN

def GetBuiltInParam(paramName):
builtInParams = System.Enum.GetValues(BuiltInParameter)
test = []
for i in builtInParams:
if i.ToString() == paramName:
test.append(i)
break
else:
continue
return test [0]

cats = IN[0]
paramName = IN[1]
pValue = IN[2]
filName = IN[3]
view = UnwrapElement(IN[4])

TransactionManager.Instance.EnsureInTransaction(doc)

catList = []
for i in cats:
catList.append(ElementId(i.Id))

typedCatList = ListElementId

bip = GetBuiltInParam(paramName)

rules = []

rules.append(ParameterFilterRuleFactory.CreateNotBeginsWithRule(ElementId(bip), pValue, 0.001))

try:
filter = ParameterFilterElement.Create(doc, filName, typedCatList, rules)

view.AddFilter(filter.Id)
view.SetFilterVisibility(filter.Id,false)

except:
pass
TransactionManager.Instance.TransactionTaskDone()

OUT = view


#2

what’s the warning?


#3

Thank you for asking. It does not give a warning. It just does not turn off the visibility.
I got that line from here:

I have seen that it should be possible to achieve what I want, because I have seen it working in your video here:


#4

it doesn’t because you have the whole thing enclosed in a TRY statement. take that out and try again.


#5

I took it out from TRY.

It still creates the filter and adds to the view, but it is still visible.


#6

Idk, Revit API works in strange ways sometimes. Try calling it like so instead: view.SetFilterVisibility(filter.Id, False) since we are in Python.

Maybe its the fact that it needs to be regenerated so perhaps call doc.Regenerate() before you call set filter visibility but after you created it.


#7

Konrad, you da real MVP
I only had to change it to " False", instead of “false”. Now it works fine. Thank you very much.


#8

@Konrad_K_Sobon where can I find this package? I have Archi-Lab Grimshaw, Bumblebee, Archi-nodes, and Archi-Nodes but the nodes aren’t included for View Filters. You went right down an avenue that’s going to help me immensely with the nodes in the video above!
(I dug around all over your website too, I didn’t want to bother you, but from the video you’re saving me many hours of “figuring it out” already!)


How to create and control View Filters
View Filter Visibility
#9

This WILL be part of Archi-lab in the future but for now, it will come out available for download with a course at Think Parametric. https://thinkparametric.com/ I think I will keep it there for a month or so and then publish to my package. I think the course for Dynamo 102 is being edited now, and should be ready in a week or two.

Ps. Also, it appears that Dynamo will be getting view filters in the next stable release of Dynamo. I saw some PRs in the works that will allow some of this functionality but I am not sure if all…its pretty limited. When it comes out I will clean out excess from my package and then offer the rest as supplemental, maybe push into the daily builds. I am not sure yet.