Get All Viewport types -node not working

Hey guys,

Im using the node get all viewport types from archi-lab. Every time I close my script and reopen it and run it …I get this message:

When I delete the node and re - place the same node it works perfectly. Do you guys know why ?

It probably won’t work if you don’t have already placed viewport.

Sounds like a race condition in the node upgrade. Confirm you’re on the latest version of Archilab. Thanks!

Here is what im working with.

Some additional info. @Tomasz_Puchala The script creats views with the default viewports. If I run the script 2 times it still doesnt work. The first time would then create some views with viewports on them and 2nd time would also create views but there would already be used viewports to read from.

Only if I delete the node and place it again from the menu it works. Even without having used viewports in the project. Eveything else is perfect about the node. Its just that I cant run the script without having to remove and then put it again.

Hi @verdi

This should work for you:

import clr
# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager

import Revit

doc = DocumentManager.Instance.CurrentDBDocument

collection = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Viewports).WhereElementIsNotElementType().ToElements()

vptypes = []
for e in collection:
	if e.Category != None:

OUT = vptypes

You could also use OOTB nodes:

1 Like

Thank you ! I will try the costum script.

The OOTB nodes don’t work, because im looking for all the viewports in the document/project. The OOTB nodes only give you the ones you have placed/used. There are 3 in project but one placed, cause there is only 1 view on the sheet.

@verdi Ah you’re looking to get viewport types?

I had a similiar problem. I coudn’t find a way to get types loaded to a template. Workflow above works only when you have already placed viewports. Otherwise, it will give you an empty list. I get viewport types in totally different way:

  • create placeholder sheet
  • place viewport on it
  • get types and some more viewports properties
  • rollback whole Transaction, so nothing is created, but you still can get viewport types .
    But I don’t know if it’s a good approach for you.
1 Like

Yes I am , but looking to get the types not used in the project yet. The python script , gets all the viewports used. It functions exactly the same as the 2 OOTB nodes " element type " and “all elements of type”.

The name of the node I would be looking for is something like, “available viewport-types in document”.

@Tomasz_Puchala That is a good idea Tomasz. I did not want to do it that way, but seeing that I don’t see any other way yet, I wil just place the view and viewports I need in the starting Revit template and let dynamo choose that one. But then the script would only work in that template.

Thanx for the reactions guys. I do not have a solution yet until the node is fixed, but will use the work around of placing the viewports in the document before running the script.

Isn’t there a way via categories?

I’ve been looking for a solution to this for quite awhile. I had a lightbulb moment and figured it out… I think. You can get one viewport that already exists. Then use GetValidTypes to access all of the viewports in the document. I don’t know if it’s necessary to filter down to floor plan viewports or not, like I did. But I’m going to run with that for now.

My code probably isn’t perfect either. I’d welcome any improvements.

Hope this helps.

import clr

#Import Revit Namespace
from Autodesk.Revit.DB import *

#Import DocumentManager
from RevitServices.Persistence import DocumentManager
#Get the current Document and application.
doc = DocumentManager.Instance.CurrentDBDocument

temp_list, outlist = [], []

#Get all Viewports in the current document.
elements = FilteredElementCollector(doc,).OfCategory(BuiltInCategory.OST_Viewports).WhereElementIsNotElementType().ToElements()

for e in elements:
	e_fam = e.get_Parameter(BuiltInParameter.VIEW_FAMILY).AsString() #Get the Viewport Family.
	if e_fam == 'Floor Plans':
		temp_list.append(e) #Create a list of Floor Plan viewports.

vp = temp_list[0] #Get a viewport from the temp_list.
viewports = vp.GetValidTypes() #Get all viewport type ids in the document.

for v in viewports:
	x = doc.GetElement(v) #Get the actual viewport elements, using its id.
	name = x.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString() #Get the viewport name.
	id = x.Id #Get the viewport id.
	outlist.append([name, id]) #Create a list of viewport names and ids.

OUT = outlist