How can I Get All Available Viewport Types?

I am trying to change a viewport to a type that exists in the model but there is not a viewport with the desired type placed.

How can I get a list of the available/loaded viewport types?

Thanks in advance

Hey,

Filtered Element Collectors are my goto for unplaced things, not the most elegant, but something like this…

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

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

output = []
for vFT in fec:
    if vFT.FamilyName == "Viewport":
        output.append(vFT)
        
OUT = output

Thanks to @SeanP

Hope that helps,

Mark

2 Likes

Thanks,
I’m not really familiar with Python yet, I’m just starting to take a class.
I will inspect and try this coding.

Thank you again for your help!

Hello @a.corriveau …archilab have a node as well…

Beautiful… I’ve just spent the last half hour wondering why mine wasn’t working… I’d tried this:

collector = FilteredElementCollector(doc).OfClass(Viewport).WhereElementIsElementType()

And it wasn’t giving me any errors (just a blank list)… Now I can see why :smiley: