Get only parameters from visibilty using Python

I want to get all the parameters of a specific element category and append only the parameters from the visibility parameter Group., I can do it in Dynamo using Nodes, But i need to iterate thru a lot of instances so i tried to do it in Python.

I tried a similar post but didn’t get any results:

I only need to get the element id of all the parameters of the element, then i can check which group it belongs to and filter the results silimar to the pseudocode attached.

isolate in view, all elements in resulting view?
There must be a Python way

1 Like

You can do it like this:

Python script:

import clr

#Import the Revit API
import Autodesk
from Autodesk.Revit.DB import *

elem = UnwrapElement(IN[0])

output = []

params = elem.Parameters

for i in params:
	pg = i.Definition.ParameterGroup
	if str(pg) == 'PG_VISIBILITY':
OUT = output
1 Like

Almost there…


I managed to filter the parameter by parameter group…but i need the output to be a "string" of the parameter name…Eg…hardware Spec 1" in this case.

The Definition object you are using to retrieve the ParameterGroup also has a Name property, which returns the Parameter’s name as a string.

Try this instead:

pg_visibility = BuiltInParameterGroup.PG_VISIBILITY
for param in params:
    pg = param.Definition.ParameterGroup
    name = param.Definition.Name
    if pg == pg_visibility:
1 Like

Ah alright. But as @cgartland showed, the Definition also has a Name property, so there’s your answer.

1 Like

Thnx @MartinSpence & @cgartland

1 Like