# ScheduleFilter using y/n

**URL:** <https://forum.dynamobim.com/t/schedulefilter-using-y-n/29698>\
**Category:** Revit\
**Tags:** schedule\
**Created:** [December 13, 2018, 9:21pm UTC](https://forum.dynamobim.com/t/schedulefilter-using-y-n/29698 "2018-12-13T21:21:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slepagetrudeau](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/slepagetrudeau/32/29983_2.png) [@slepagetrudeau](https://forum.dynamobim.com/u/slepagetrudeau)\
**Post date:** [December 13, 2018, 9:21pm UTC](https://forum.dynamobim.com/t/schedulefilter-using-y-n/29698/1 "2018-12-13T21:21:48Z")

</div>

Long time no see, forum,

Problematic node: ScheduleFilter.ByFielsTypeAndValue

What I expected: Creation of filters that could be used to deal with yes/no parameter

What I got:

- Impossible to cast ‘System.Boolean’ into ‘Revit.Elements.Element’.
- Impossible to cast ‘System.Int64’ into ‘Revit.Elements.Element’.

I tried using:  
Integer,  
boolean,  
string converted to int  
value taken from a manually created filter

It used to work by using 0 and 1 as false and true. I get that it want to be fed a Revit.Elements.Element, but how do I create one? Also, the filter creation works with string, but it’s no use as the schedule itself wont take it.

 ![Sans%20titre](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/c/6c731016db7ae15be404bc7299d6dc0d98289768.png)  
 ![2018-12-13_1618](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/8/085d9af0d59d1d8a60939d77a991cc24360fc766.png)  
n’est pas égal == not equal  
Non == No

---

<div class="post-metadata">

**Author:** ![slepagetrudeau](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/slepagetrudeau/32/29983_2.png) [@slepagetrudeau](https://forum.dynamobim.com/u/slepagetrudeau)\
**Post date:** [December 14, 2018, 3:20pm UTC](https://forum.dynamobim.com/t/schedulefilter-using-y-n/29698/2 "2018-12-14T15:20:20Z")

</div>

I’m gonna assume it’s a problem with the node.

So I just rebuilt my own in python and now it works. It’s always good to find an excuse to get better with the API.

Since I posted the question, here’s the answer:  
 ![2018-12-14_1016](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/5/8575f23c7cf7a22673c8041cf907c7d99e7c35ed.png)

```
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Dynamo Example
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
# RevitServices
clr.AddReference(&quot;RevitServices&quot;)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# doc and uiapp

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

Views = IN[0]
FieldId = IN[1]
Value = IN[2]

Filters = list()
for Id in FieldId:
F = ScheduleFilter( ScheduleFieldId( Id ), ScheduleFilterType.NotEqual, Value )
Filters.append(F)

TransactionManager.Instance.EnsureInTransaction( doc )

for View, Filter in zip( Views, Filters):
( UnwrapElement( View ).Definition ).InsertFilter( Filter,0 )

TransactionManager.Instance.TransactionTaskDone()

OUT = IN[0]
```
