Assigning values for the "Key-name" parameter in a Key Schedule parameter

I’m starting to learn Dynamo, and I’ve faced mysefl struggling to set the value for a Key Schedule.

I got the Key Schedule parameter “BitolaPressão”, and I want to use Dynamo to write this value in some duct sections, based on a list.
The problem is that the first value of the list is being repeated for all the Names of the schedule, and I want to match the value “line by line” from my input list. Must be a list structure problem, but I didn’t find info on writing info on the “Key-name” parameter inside a Key Schedule parameter.


i do not have straigt forwart solution but here some snippets to get closer

#📦 Variables
p_key_name   = 'Room Style' # Write Your Key-Param Name!
key_schedule = None

#1️⃣ Get all Schedules
all_schedules = FilteredElementCollector(doc)\

#2️⃣ Get Key-Schedule            
for schedule in all_schedules:
        if schedule.KeyScheduleParameterName == p_key_name:
            key_schedule = schedule

#💡 Ensure you found matching schedule
if not key_schedule:
    forms.alert("Can't find matching Schedule.\nPlease Try Again.",
#3️⃣ Get Possible Key-Parameter Values
key_values = FilteredElementCollector(doc, key_schedule.Id).ToElements()
dict_key_values = {key.Name : key.Id for key in key_values}

#OUT = 

you have to adapt it to your project… this stuffs runs currently in PyRevit

t = Transaction(doc,'Change KeyParam')
t.Start()  # 🔓

random_id = dict_key_values.values()[0]
p_key     = room.LookupParameter(p_key_name )

t.Commit() # 🔒



1 Like