Remove Specific Schedule Filter Without Clearing All

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?

image

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.

1 Like

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.

1 Like

This is like 90% of my job lately. :rofl:

1 Like

I can confirm that it works :slight_smile:
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!

5 Likes

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!

image

1 Like