# Viewports - Listing Available Element Types

**URL:** <https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238>\
**Category:** Revit\
**Tags:** dynamo, views\
**Created:** [April 1, 2019, 1:36pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238 "2019-04-01T13:36:19Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 1, 2019, 1:36pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/1 "2019-04-01T13:36:19Z")

</div>

hi Everyone,

I’m looking for a bit of assistance with the below thread:

> [@How to set Viewport Type?](https://forum.dynamobim.com/t/how-to-set-viewport-type/7200/28):
>
> [image] got that fixed by getting the most recent package…however it doesnt seem to work on schedules.

The method shown by Konrad is clear enough to follow, but it relies on the viewport type being in use (within the project) and using indexes to filter the element to obtain the element with the desired parameter value.

What I’m after is setting my viewports to a specific type by name “No Title”. Is there a way to list the value types like we can do with Family.Types Node?

Thanks,

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [April 1, 2019, 3:38pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/2 "2019-04-01T15:38:58Z")

</div>

This python code should work:

```
import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
clr.AddReference('RevitServices')
import RevitServices

from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc).OfClass(ElementType).ToElements()

viewportTypes = []

for e in collector:
	p = e.get_Parameter("Title")
	if not p is None:
	  if p.AsValueString()=="M_View Title":
	  	viewportTypes.append(e)

#Assign your output to the OUT variable.
OUT = viewportTypes

```

![Przechwytywanie](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/81d56345065e82ce21b14688821fd8be4eaebc2e.png)

---

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 1, 2019, 3:57pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/3 "2019-04-01T15:57:39Z")

</div>

hi @maciek.glowka,

Thanks for the quick response and with a custom piece of python!

I’ve tried using your python and I’m getting the following error…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/5/f5beb3e37d300236f04c690d4945d9e0059eee9c.png)

I also tried it as you have it shown (nothing connected to the “IN[0]” Port).

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/75d1daf461afe332825c0a763893ec1345d4b753.png)

Any ideas?

Thanks,

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [April 1, 2019, 4:03pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/4 "2019-04-01T16:03:05Z")

</div>

I was testing on a quite old Revit version. I think in a newer API you might wanna use LookupParameter instead of get\_Parameter…Sorry about that.  
As of the IN part - nothing should be connected

---

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 2, 2019, 8:55am UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/5 "2019-04-02T08:55:13Z")

</div>

hi @maciek.glowka,

I have done as directed and replaced:

p = e.get\_Parameter ("Title")

with

p = e.LookupParameter ("Title")

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/5/d59d83f2c32f60e932508d75ddbba9feef42e930.png)

The code is erroring this time but its not finding any information either.

Thanks,

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [April 2, 2019, 9:37am UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/6 "2019-04-02T09:37:41Z")

</div>

Hmm…I’ve tried on a newer Revit version and it worked…maybe your types have different title names eg.  
Can you maybe upload the file to examine?

Or you could also change part of the code to this:

```
for e in collector:
  p = e.LookupParameter("Title")
  if not p is None:
    viewportTypes.append(p.AsValueString())

```

and see what titles come out

![Przechwytywanie](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/8/9828adf8ac788d23551de7008ce4b7197247f33b.png)

---

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 2, 2019, 3:14pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/7 "2019-04-02T15:14:02Z")

</div>

hi @maciek.glowka,

I have modified the code as required. Getting information from the python script node but its erroring on the Element.Name as the output from the python are strings.

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

> [@maciek.glowka](#):
>
> maybe your types have different title names

In regards this, I have a few types yes. The View Titles are duplicating as the option shown extension is checked in one and unchecked in the other.

The View Title that appears three titles as it covers the types: no line, with line and Show Title unchecked.

(Took me a while to work out that what is being shown is the “Title” value under the type properties for the viewports).

In regards to document upload…

[View Title Assistance Sample.rvt](https://forum.dynamobim.com/uploads/short-url/mdTJVyw1tntSn0xzYOYxB7Jhif2.rvt) (1.3 MB)

Thanks for your continued help. 🙂

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 2, 2019, 4:02pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/8 "2019-04-02T16:02:25Z")

</div>

Hi @ben.dowling

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

---

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 2, 2019, 4:12pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/9 "2019-04-02T16:12:09Z")

</div>

HI @Kulkul,

Yes that looks like what i’m after. How did you get that list to appear?

As there are 9 “Element Types” with the 9 viewport type references were each assigned to a view prior to the extraction?

Thanks,

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 2, 2019, 4:23pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/10 "2019-04-02T16:23:44Z")

</div>

> [@ben.dowling](#):
>
> How did you get that list to appear?
> 
> As there are 9 “Element Types” with the 9 viewport type references were each assigned to a view prior to the extraction?

Hahaha That’s the magic with few lines of python 🕶

```
import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices

from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

fec = FilteredElementCollector(doc).OfClass(ElementType).ToElements()

vpt = []
names=[]
for f in fec:
  p = f.LookupParameter('Title')
  if not p is None:
    vpt.append(f)
    names = [Element.Name. __get__ (i) for i in vpt]

OUT = vpt, names

```

Please mark the post as solved. You’re Welcome!

---

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 2, 2019, 4:41pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/11 "2019-04-02T16:41:57Z")

</div>

hi @Kulkul,

Would love to do so but I’ve got another error popping up…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/7/2777f746d1360c9edd1dd33096103b0b2fef0049.jpeg)

Is there something I need to download or something?

Thanks,

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 2, 2019, 4:53pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/12 "2019-04-02T16:53:08Z")

</div>

Could you show me code inside Python Script?

Did you copy pasted above code inside python script?

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [April 2, 2019, 5:08pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/13 "2019-04-02T17:08:25Z")

</div>

This modification was for test purposes only…to see what kind of parameter values you have in your project. It seems that you should look for “View Title” string instead of “M\_View Tilte” (as was in my code)…

so you can try this one…hope it works now for you

```
import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
clr.AddReference('RevitServices')
import RevitServices

from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc).OfClass(ElementType).ToElements()

viewportTypes = []

for e in collector:
  p = e.LookupParameter("Title")
  if not p is None:
    if "View Title" in p.AsValueString():
      viewportTypes.append(e)

#Assign your output to the OUT variable.
OUT = viewportTypes

```

 ![Przechwytywanie](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/0/8016426003a1e409b2d8384bacbb0df1022b19dc.png)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [April 3, 2019, 6:12am UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/14 "2019-04-03T06:12:04Z")

</div>

Why not just use OOTB nodes with Element Types and All Elements of Type?

> [@How to modify a viewport's "Title" parameter (family type parameter) based on the viewports "View Name" Parameter](https://forum.dynamobim.com/t/how-to-modify-a-viewports-title-parameter-family-type-parameter-based-on-the-viewports-view-name-parameter/7806/7):
>

---

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 3, 2019, 12:07pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/15 "2019-04-03T12:07:39Z")

</div>

hi @SeanP,

I was using this method originally, but I wanted to see the available options in the viewport types. This option requires there to be a viewport with the desired View Title Type to be in use in order for it to be used.

@Kulkul - Yes I pasted your code within the ‘Python Script’ Node. See below:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/d/5d817e89f6ac0fb7cb71027391651eb0efe1712d.png)

@maciek.glowka - That did it. Thanks so much. I have provided my graph below in case it is usual for another member of the forum. 🙂

The completed graph’s function is to:

Select all Sheets within Active Document and insert [Legend] at a point indicated.  
It then takes these newly added viewports and runs it through the second tier of the script. Changing their viewport types from the default to my preference of “No Title”

 ![Place%20Legend%20on%20A1%20Sheets](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/b/dbc8055dc69df832a9edb11c5e865acac24450b8.png)

[Place Legend on A1 Sheets.dyn](https://forum.dynamobim.com/uploads/short-url/z06xREfF13KXJI0KzE5OuIN5qoC.dyn) (50.7 KB)

Thanks for all the help!

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 3, 2019, 3:31pm UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/16 "2019-04-03T15:31:51Z")

</div>

> [@ben.dowling](#):
>
> Yes I pasted your code within the ‘Python Script’ Node.

@ben.dowling you didn’t paste completely. Please have closely look at my code above before you say it didn’t work, you missed to add output.

`OUT = vpt, names`

---

<div class="post-metadata">

**Author:** ![ben.dowling](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ben.dowling/32/68614_2.png) [@ben.dowling](https://forum.dynamobim.com/u/ben.dowling)\
**Post date:** [April 4, 2019, 8:21am UTC](https://forum.dynamobim.com/t/viewports-listing-available-element-types/34238/17 "2019-04-04T08:21:24Z")

</div>

@Kulkul,

Ah i didn’t notice the scroll bar to the side! 🤦‍♂️ Sorry about that.

I have added that script to the process and can confirm it works perfectly. 🙂
