Obtaining list of all elements of a Revit model

Hello everyone,

I’m trying to obtain a list of all the elements of a Revit model whose categories are associated to a specific shared parameter, using only native Dynamo nodes.

To achieve this result, I initially used a Python node whose code was generated by AI. It did work, but whenever changes were made to the model and/or to the categories associated with that shared parameter, that single node broke and caused the entire script to fail. I also need the script to be as linear and readable as possible, so that my colleagues can easily understand it and maintain it in the future, and this is why I want to substitute the Python node with native ones.

I then came across Genius Loci’s node “Get Shared Parameter”, but even though a shared parameters .txt file is correctly linked to the project, the node does not return any result.

For this reason, I eventually convinced myself that I would also be satisfied with “just” obtaining a list of all the elements in the model, but even this seems to be more challenging than expected.

So, I’m kindly asking for your support to find a solution.

Thank you in advance for your help,

Maria Paola

Hello. In general it’s recommended to share your solution at first, by posting the graph image of code.

If your shared parameters added as project parameters, you can use this node from Clockwork package. And then filter out the list to keep only desired SharedParameterElement(s) and corresponding categories.

You could do it with OOTB nodes but it is far easier with Python if you know the API

import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import ElementParameterFilter, FilteredElementCollector, ParameterFilterRuleFactory

doc = DocumentManager.Instance.CurrentDBDocument

bic = UnwrapElement(IN[0]).BuiltInCategory
sp_name = IN[1]

pfrf = ParameterFilterRuleFactory.CreateSharedParameterApplicableRule(sp_name)

epf = ElementParameterFilter(pfrf)

OUT = FilteredElementCollector(doc).OfCategory(bic).WherePasses(epf).ToElements()