I can add filters to a schedule, but is there a way to remove them? I see ClearAllFilters, but I want to remove a specific filter and leave others untouched. Am I missing something?
Iām pretty sure the only way would be to clear filters then re-add all but the intended ones. If you try to remove a filter in Revit naturally, youāll notice it wipes out all filters below it, so pretty sure Dynamo would suffer from this if it supported removal.
Would this node suit your requirements?
I think itās be doable via the API. There is a āremove filterā method that takes the Element Id of the Filter element. There is also a GetOrderedFilters method to get a list of the filters in the order provided. Only question is if the filters provided differ between schedules and views as these are inherited methods. You might have to enable/disable the filters as you go, or force a regen though. Worth poking around of there is desire and someone has time.
Interestingā¦ maybe they built it in as a helper behind the scenes to avoid the filter collapse. Iāll try to get a look into this shortly, as I feel like I didnāt get this to work another time I was trying to define filters in schedules. Maybe I can prove past me wrong.
This is like 90% of my job lately.
I can confirm that it works
It is possible to remove one filter without effecting the others.
Notice that these method for schedules does not take an element id, it works by index.
ItĀ“s the method for views that takes an id.
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import ViewSchedule
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
schedule = UnwrapElement(IN[0])
TransactionManager.Instance.EnsureInTransaction(doc)
# remove filter by index
schedule.Definition.RemoveFilter(0)
TransactionManager.Instance.TransactionTaskDone()
@SURFACEFUSION , if you are not already familiar with that procedure, you will need a python script node and copy/paste the code!
This worked beautifully! I swapped out the ā0ā in the schedule.Definition.RemoveFilter for an āIN[1]ā and I was able to input both the scheduleView and the index of the filter to remove. Thanks for all your help!