# Get only parameters from visibilty using Python

**URL:** <https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411>\
**Category:** Developers\
**Created:** [February 20, 2019, 4:47pm UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411 "2019-02-20T16:47:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashwinash112](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@ashwinash112](https://forum.dynamobim.com/u/ashwinash112)\
**Post date:** [February 20, 2019, 4:47pm UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411/1 "2019-02-20T16:47:35Z")

</div>

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:

> [@Parameter from ParameterElement](https://forum.dynamobim.com/t/parameter-from-parameterelement/29783):
>
> How get Parameter from ParameterElement ?

 ![Parameters](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/0/80d1a3529784039209c620a770f61fc936d80f98.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 20, 2019, 7:38pm UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411/2 "2019-02-20T19:38:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [February 20, 2019, 8:25pm UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411/3 "2019-02-20T20:25:42Z")

</div>

You can do it like this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/9/4999c94967eeafd787b59ccea0cda420ca71477e.png)

Python script:

```
import clr

#Import the Revit API
clr.AddReference('RevitAPI')
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':
		output.append(pg)
	
OUT = output
```

---

<div class="post-metadata">

**Author:** ![ashwinash112](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@ashwinash112](https://forum.dynamobim.com/u/ashwinash112)\
**Post date:** [February 21, 2019, 2:32am UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411/4 "2019-02-21T02:32:23Z")

</div>

Almost there…

![Parameters%201](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/3/835c8753aa2c9f11fd8a7fdf5dfb5093f5967197.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![cgartland](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cgartland/32/45378_2.png) [@cgartland](https://forum.dynamobim.com/u/cgartland)\
**Post date:** [February 21, 2019, 4:55am UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411/5 "2019-02-21T04:55:35Z")

</div>

The Definition object you are using to retrieve the ParameterGroup also has a [Name](http://www.revitapidocs.com/2018.1/a8f22807-7fef-f24e-e1fa-7dbef20c3628.htm) 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:
        output.append(name)
```

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [February 21, 2019, 7:22am UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411/6 "2019-02-21T07:22:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ashwinash112](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@ashwinash112](https://forum.dynamobim.com/u/ashwinash112)\
**Post date:** [February 21, 2019, 7:25am UTC](https://forum.dynamobim.com/t/get-only-parameters-from-visibilty-using-python/32411/7 "2019-02-21T07:25:33Z")

</div>

Thnx @MartinSpence & @cgartland
