Get Sheets From Document

Hi - I’m attempting to grab all sheets from a given document. I’ve used a clockwork node that collected all the views as the basis and just changed the class that is collected:

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

inputdoc = UnwrapElement(IN[1])
if inputdoc == None:
	doc = DocumentManager.Instance.CurrentDBDocument
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.RevitLinkInstance":
	doc = inputdoc.GetLinkDocument()
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document":
	doc = inputdoc
else: doc = None

collector = FilteredElementCollector(doc)
views = collector.OfClass(ViewSheet).ToElements()
viewlist = list()
for view in views:
	viewlist.append(view)
OUT = viewlist

Can you show the inputs for the python node? It is hard to tell what you are inputting and IN[0] isn’t even referenced in the script.

Sure - I’m trying to collect all views and sheets from the document to delete the ones I don’t need to issue. The python is copied from the clockwork node shown.

Can you show what the output of Application.OpenDocumentFile is? It might not be Autodesk.Revit.DB.Document, but Revit.Application.Document, which would throw up an error.

Turns out it was sending null - probably because I had been testing too many things and the file was still loaded in memory somewhere. It’s now working so all good.

2 Likes