Get schedule filters

Hi,

I’m trying to get the filters from schedules and the OOTB node gives a strange error.

So I decided to try my hand at making a python script for it. I got it to work better than the OOTB node, but for some reason what it outputs is different.

I guess I could work with it as is, but I just wanted to understand why I’m getting a different output.

What I noticed is if I hook up one of the other OOTB nodes to mine, like ScheduleFilter.Value or ScheduleFilter.FieldId, it tells me that it expects ScheduleFilter but I’m giving it Object[]. While in python, if I tell it to [f.FieldId for f in sfilters] for example, it works fine.

I tried taking a look at the dynamo source code, but I wasn’t able to piece together how they work. I’m relatively new to the API and coding in general.

I pasted my script below along with screenshots of the nodes from the source for reference. If anyone with more experience has any ideas, that would be great.

source schedule filters

source internal schedule

import clr

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

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

scheds = tolist(UnwrapElement(IN[0]))

outList = []

for s in scheds:
	sfilters = s.Definition.GetFilters()
	outList.append(sfilters)

OUT = outList
1 Like