p_key_name = 'Room Style'
key_schedule = None
all_schedules = FilteredElementCollector(doc)\
.OfCategory(BuiltInCategory.OST_Schedules)\
.ToElements()
for schedule in all_schedules:
try:
if schedule.KeyScheduleParameterName == p_key_name:
key_schedule = schedule
break
except:
pass
if not key_schedule:
forms.alert("Can't find matching Schedule.\nPlease Try Again.",
exitscript=True)
key_values = FilteredElementCollector(doc, key_schedule.Id).ToElements()
dict_key_values = {key.Name : key.Id for key in key_values}
print('Key Parameter: {}'.format(p_key_name))
print('Matching Schedule: {}'.format(key_schedule.Name))
for k,v in dict_key_values.items():
print(k,v)