Hi all, I have been recently learning python but cant seem to figure out why this code wont work, i found this code for adding the “HasParameter” Filter onto my schedules which works if you feed the script a direct view but if its a list of views, it throws this error
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 22, in
AttributeError: ‘List[object]’ object has no attribute ‘ViewType’
Thank you for any help, and a explaination would also be helpful!
Code Below:
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")