How do I access a particular shared parameter of a family using python script

Hi all,

I can access info of a family of all pipes in a view i have coalited in a list using a dynamo node but i would like to do it inside a python script as the way i am doing it at the moment is resulting in to many nodes in my dynamo script (as I’m accessing multiple shared parameters across the family) .

Can anyone tell me how best to do this?

Thanks in advance :slight_smile:

What have you tried so far?
Please review How to get help on the Dynamo forums

You can use a list and node list level to get large amounts of info with only a few nodes

Hi Mike,

Thanks for the reply, I am doing it as you shown above but i have a lot of parameters to access as it is for a fabrication document. As I am accessing so much information there ends up being an awful lot of lists/nodes.

I am using some python script nodes in my code already and I was hoping to figure out how I can access the shared parameters within the python node to somewhat clean up the dynamo script.

I have tried a few different lines of code to access the parameters but I cant seem to get the code to run once i try and access a specific parameter within the python code. So i have to access the shared parameter values with a python node and feed it into the code as a list. This is making the code very bloated and i would love to avoid this if possible :slight_smile:

Thanks again
Gar

Here is one way to get shared parameters and collect associated elements per parameter

import clr

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

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


def epf(param_id):
    return ElementParameterFilter(
        ParameterFilterRuleFactory.CreateHasValueParameterRule(param_id.Id)
    )


doc = DocumentManager.Instance.CurrentDBDocument

cat = UnwrapElement(IN[0])

"""  # Not used
cat_elements = (
    FilteredElementCollector(doc)
    .OfCategory(cat.Id.Value)
    .WhereElementIsNotElementType()
    .ToElements()
)
"""

shared_params = (
    FilteredElementCollector(doc).OfClass(SharedParameterElement).ToElements()
)

fec = FilteredElementCollector(doc)

OUT = [
    (sp.Name, fec.WherePasses(epf(sp)).OfCategory(cat.Id.Value).ToElements())
    for sp in shared_params
]

thanks for the above - will try get it implemented in the scirpt asap :slight_smile: