Hi
I am trying to create an excel file with a list of all doors and all rooms per sheet. Right now I am stuck with pulling the data from the views.
I have a list of sheets and a list of categories and I want to receive a nested dictionary to further process the data towards the excel file:
The dictionary (even though not sorted) is structured as intended but I am struggling to collect the elements from the views per sheet.
This is the python code that I am working on:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
def tolist(input):
tolist = input if isinstance(input, list) else [input]
return tolist
def uwlist(input):
tolist = input if isinstance(input, list) else [input]
unwrap = UnwrapElement(tolist)
return unwrap
def supercollector(sheet,category):
viewsofsheet = sheet.GetAllViewports()
elems = []
for view in viewsofsheet:
elems.append(FilteredElementCollector(doc,view.Id).WhereElementIsNotElementType().ToElements())
return elems
sheets = uwlist(IN[0])
categories = tolist(IN[1])
output = {sheet.SheetNumber:
{cat.Name: supercollector(sheet,cat)
for cat in categories}
for sheet in sheets}
OUT = output
I tried this but I get the following error:
AttributeError : 'ElementId' object has no attribute 'Id' [ File "<string>, line 46, in <module>\n',' File "<string>, line 47, in <dictcomp>\n',' File "<string>, line 47, in <dictcomp>\n',' File "<string>, line 36, in <supercollector>\n']
Line 36 is my supercollector function
Line 46/47 are the output lines and call of that function
The data structure (as shown above) is as intended but the ElementCollector doesnât collect. Do I have to unwrap the views on my sheets as well or are they unwrapped as soon as I unwrap the sheets? Or do have to use a different method?
I have not yet implemented the category filter because I thought there is no point as long as I canât collect any elements at all.
Thank you in advance for any help.



