ScheduleFilter using y/n

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.


2018-12-13_1618
n’est pas égal == not equal
Non == No

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

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("RevitServices")
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]
2 Likes