The best way to collect parameter values from multiple models

Hello everyone, what is the best way to collect parameter values from multiple models, preferably in a manner that can be automated through a task scheduler or another method?

I have a list of parameters, the values of which I want to extract from a list of models. I tried using the CLI, but I encountered an issue where the model opens but cannot proceed beyond the worksets selection window and doesn’t close.

Something decently robust would be Revit Batch Processor.
The cli pyrevit run is also ok. You have to specify open options properly.

1 Like

if i use cli pyrevit, i have this problem


Open workset default: “Specify…”

from pyrevit import HOST_APP,DB,script
from Autodesk.Revit.DB import Element
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory

output= script.get_output()
output.close_others()

filepath = __models__[0]
open_options = DB.OpenOptions()
open_options.DetachFromCentralOption = DB.DetachFromCentralOption.DetachAndPreserveWorksets
worksetConfiguration = DB.WorksetConfiguration(DB.WorksetConfigurationOption.CloseAllWorksets)
open_options.SetOpenWorksetsConfiguration(worksetConfiguration)
model_path = DB.ModelPathUtils.ConvertUserVisiblePathToModelPath(filepath)

uidoc = HOST_APP.uiapp.OpenAndActivateDocument(model_path, open_options, False)
doc = uidoc.Document


def get_parameter_value_by_name(element, parameterName):
    return element.LookupParameter(parameterName).AsValueString()

def all_elements_of_category(category):
    return FilteredElementCollector(doc).OfCategory(category).WhereElementIsNotElementType().ToElements()

Thank you! This is very usfull !

To be able to use the same script both with the current model and in batch, I created a python decorator that checks if the shift key is pressed, asks the user for the rvt files to process, opens them one by one, calling the decorated function and optionally saves them.

Obviously the scripts have to be refactored as functions, with the main one accepting a model/document as its argument.

I will post it in the showcase category as soon as I have time.

Thanks for the answer !
I will wait

Sorry I thought the forum would create backlinks automatically, here it is:

2 Likes