# Assigning Filters with ScheduleView.AddFilters node by using two Lists

**URL:** <https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904>\
**Category:** Revit\
**Tags:** python, dynamo\
**Created:** [November 30, 2021, 3:51pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904 "2021-11-30T15:51:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephenDini](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/stephendini/32/127724_2.png) [@StephenDini](https://forum.dynamobim.com/u/StephenDini)\
**Post date:** [November 30, 2021, 3:51pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/1 "2021-11-30T15:51:55Z")

</div>

I have two lists being passed along into ScheduleView.AddFilters, one contains a list of ScheduleViews and the other a list of ScheduleFilters. My current issue is I am getting a warning as if I am trying to add over 8 filters to one schedule, where instead, I am trying to assign one per schedule. If I send over the list of ScheduleViews and **one** ScheduleFilter it works but assigns the wrong filter of coarse.

I do not know if this is the reason but why is the list of ScheduleViews spaced differently to the list of ScheduleFilters?

Should I nix the Node and create a python script node to assign the filters? Am I using the ScheduleView.AddFilters Node incorrectly?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/2/32c61e49f9550da5955962cd8062d6f75b574a0e.png)

Thank you for your time.

---

<div class="post-metadata">

**Author:** ![staylor](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/staylor/32/94307_2.png) [@staylor](https://forum.dynamobim.com/u/staylor)\
**Post date:** [November 30, 2021, 9:03pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/2 "2021-11-30T21:03:45Z")

</div>

As long as you have the same number of schedules to filters, you could try setting the lacing to longest and see if that works.

---

<div class="post-metadata">

**Author:** ![staylor](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/staylor/32/94307_2.png) [@staylor](https://forum.dynamobim.com/u/staylor)\
**Post date:** [November 30, 2021, 9:04pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/3 "2021-11-30T21:04:36Z")

</div>

BTW…welcome to the community!

---

<div class="post-metadata">

**Author:** ![StephenDini](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/stephendini/32/127724_2.png) [@StephenDini](https://forum.dynamobim.com/u/StephenDini)\
**Post date:** [November 30, 2021, 9:52pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/4 "2021-11-30T21:52:22Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![StephenDini](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/stephendini/32/127724_2.png) [@StephenDini](https://forum.dynamobim.com/u/StephenDini)\
**Post date:** [November 30, 2021, 10:04pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/5 "2021-11-30T22:04:37Z")

</div>

I learned about Lacing after I had noticed that this was the cause of a few issues others had but sadly in my cause, none of the Lacing options worked.

I did fix the issue using python but that also had its own weird issues. I figured I could create a new filter and assign the filter within the same for loop but it was adding every filter I created to each schedule I created.

In order to get the python method to work I had to use a for loop and zip the scheduled and filters, which does what I thought my original idea would do. I suspect that there was some issues with the data not being overwritten correctly but I did try to Dispose the data without success.

```auto
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# The inputs to this node will be stored as a list in the IN variables.
schedule_views = UnwrapElement(IN[0])
field = ScheduleFieldId(0)

target_definitions = []
target_filters = []

# Place your code below this line

TransactionManager.Instance.EnsureInTransaction(doc)
count = 0

for view in schedule_views:
	target_def = view.Definition
	target_definitions.append(target_def)

for view in schedule_views:
	single_filter = ScheduleFilter(field, ScheduleFilterType.Equal, view.Name)
	target_filters.append(single_filter)
	
for this_def, this_filter in zip(target_definitions, target_filters):
	this_def.InsertFilter(this_filter, 0)
	
	
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable.
OUT = schedule_views

```

I don’t want to mark this as solved because I would like to know how to correctly use the node but it may not be possible.

---

<div class="post-metadata">

**Author:** ![Hamish](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Hamish](https://forum.dynamobim.com/u/Hamish)\
**Post date:** [November 30, 2021, 10:16pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/6 "2021-11-30T22:16:37Z")

</div>

Looks like a list levels issue. Set your inputs to Views @L2 and Filters @L1 and it should work.

I believe this node is expecting the filters to be one level deeper in list nesting with the default inputs. Either it’s a single view and a list of filters, or a list of views and a list of lists of filters.

---

<div class="post-metadata">

**Author:** ![StephenDini](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/stephendini/32/127724_2.png) [@StephenDini](https://forum.dynamobim.com/u/StephenDini)\
**Post date:** [November 30, 2021, 10:37pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/7 "2021-11-30T22:37:04Z")

</div>

I attempted your solution and it no longer errors but it only sets the value to the first in the filter list. So each view is filtered by the same value. I will mess with this some more tomorrow, Thank you for your time.

EDIT:

I thought the same as you did also and tried a bunch of way to organize the filter list all with no success.

---

<div class="post-metadata">

**Author:** ![Hamish](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Hamish](https://forum.dynamobim.com/u/Hamish)\
**Post date:** [November 30, 2021, 10:48pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/8 "2021-11-30T22:48:12Z")

</div>

Try @L1 on both then, or flip the L1/L2 around. Just shooting from the hip, would have to pull up a project to see for sure. Doing a list.chop on your filters list at length 1 and using the default inputs without levels should also do the trick to get your filters 1 level deeper than your views.

---

<div class="post-metadata">

**Author:** ![StephenDini](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/stephendini/32/127724_2.png) [@StephenDini](https://forum.dynamobim.com/u/StephenDini)\
**Post date:** [December 22, 2021, 7:09pm UTC](https://forum.dynamobim.com/t/assigning-filters-with-scheduleview-addfilters-node-by-using-two-lists/70904/9 "2021-12-22T19:09:27Z")

</div>

Sorry for the late response I got busy. List.Chop actually worked and was simpler than my own python solution.

Thank you!
