Hello everyone,
I’ve been working on a subject for some time, the idea is to export a door schedule on revit to automatically make an Excel spreadsheet with particular cell formats. I’ve managed to do so, but now I need to generate the opposite effect ; import the Excel spreadsheet to modify the schedule on Revit. The problem I’m having is that some of the values of some of my parameters are conditioned by a key schedule integrated into my project template. I started working on a test function that would enable me to understand how to modify the values in my schedule. Here, for example, I’m trying to modify all the cells in my “_FINITION_PORTES” column corresponding to the types of finish on my doors.
def modify_door_finish():
# This function modifies the door finish parameter for all doors in the active view.
# Get the current Revit document
doc = revit.doc
# Get the active view
view = revit.active_view
# Define the parameter name to be modified
parameter_name = "_FINITION_PORTE" # Name of the finish parameter
# Define the new value to be set in the finish parameter
new_value = "Finition thermolaquée pour porte métallique"
# Collect all doors in the document
doors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
# Start a Revit transaction to group all parameter modifications
with Transaction(doc, "Modify Door Finishes") as transaction:
transaction.Start()
# Iterate through each door in the collection
for door in doors:
# Check if the parameter exists on the door element
door_finish_parameter = door.LookupParameter(parameter_name)
if door_finish_parameter:
# Set the new value to the parameter
door_finish_parameter.Set(new_value)
# Commit the transaction to apply the changes
transaction.Commit()
# Display a message box indicating successful completion
UI.TaskDialog.Show("Success", "Modifications completed successfully")
When I execute my code, I don’t get any errors, but no changes have been made. However, if I change the parameter to set in my code, to modify the content of another parameter (not conditioned by a key schedule), no problem, everything works correctly. I don’t know if it’s possible to operate directly in a schedule on a value conditioned by a key schedule (even if the new value is already contained in the key schedule).
Does anyone here have any ideas?