Get Views & sheets From ViewSet

I need to get a list of the sheets from a ViewSet and could not find a node to do so. The goal is to filter these sheets out of a full list of sheets to create a new ViewSet with the remaining sheets.

I found this post on the forum Get views from viewset? but I don’t know enough about python to understand how the OP’s problem was solved.

I tried to replicate the answer that @Kulkul gave in the post above. This is what I have.

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

viewSet = UnwrapElement(IN[0])

viewSets = FilteredElementCollector(doc).OfClass(ViewSheetSet)

for i in viewSets:
	if i.Name == viewSet.Name:
    	vs = i
    else:
    	continue


OUT = [i.ToDSType(True) for i in vs.Views]

One thing I’m not sure about is if the Script that I duplicated was supposed to get the list of sheets on it’s own, or if it should have been incorporated into the OP’s Script in some way. Any help or advice wold be appreciated.

Also this is my very first post so sorry if the script or image didn’t get added right.

Hi @manderson557,

I can’t really see your image at all, but can you try these 2 nodes instead…

Collector.ViewSheetSets | Py
To get all the ViewSheetSets in your Revit Document, you can use this (although I’m sure there are some nodes for it)…

##### Imports #####
import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc =  DocumentManager.Instance.CurrentDBDocument

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

##### Main #####
OUT = FilteredElementCollector(doc).OfClass(ViewSheetSet).ToElements()

ViewSheetSet.GetViewsAndSheets | Py
If given a ViewSheetSet it will return a nested list of Views and Sheets…

##### Imports #####
import clr

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

##### Definitions #####

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

##### Inputs #####
viewSet = tolist(UnwrapElement(IN[0]))[0]

##### Main #####

# Get views from ViewSheetSet...
views = viewSet.Views

# OUT = Views, Sheets...
OUT = [v for v in views if not v.ViewType == ViewType.DrawingSheet], [s for s in views if s.ViewType == ViewType.DrawingSheet]

Use your own logic in between the nodes to filter out what one you want…

EDIT :

Here is an image of them hooked up for completeness…

Cheers,
Dan

1 Like