Schedule Filter for Parameter Exists condition

Hi all,

I am not able to filter schedule when trying to use HasParameter as filter Type for filtering schedule.
Tried setting value as null, true, ""; (empty).

Alternatively, I also tried setting filter Type as GreaterThan and value as " "; (empty) but it does not work.

Hi @theshysnail,
Try this:

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

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

def fieldId(schDefinition, fieldName):
	OrderedFields = schDefinition.GetFieldOrder()
	for x,id in enumerate(OrderedFields):
		field = schDefinition.GetField(id)
		if field.GetName() == fieldName:
			return schDefinition.GetFieldId(x)
	return None       

schedule = UnwrapElement(IN[0])

OUT = []

if schedule.ViewType == ViewType.Schedule:
	try:
		definition = schedule.Definition
		field = fieldId(definition,IN[1])		
		TransactionManager.Instance.EnsureInTransaction(doc)		
		filter = ScheduleFilter(field, ScheduleFilterType.HasParameter)
		definition.AddFilter(filter)		
		TransactionManager.Instance.TransactionTaskDone()		
		OUT.append(schedule)
	except:
		OUT.append("Check Field Name")
else:
	OUT.append("Input View is not a Schedule")
1 Like