import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
# Get the current document
doc = DocumentManager.Instance.CurrentDBDocument
element_types = FilteredElementCollector(doc).OfClass(ElementType).WhereElementIsElementType()
filteredList = []
for el in element_types:
if "ViewFamilyType" in str(el):
filteredList.append(el)
OUT = filteredList
If I output the element_types they look like this:
However, if I output the filteredList I get:
I am so confused!
Also this isn’t what I was trying to do. I want to grab all the viewport types.
The elements in filteredList are being translated back into their Dynamo wrappers.
As @BenSaci guessed, that happens when elements are in a list. (You can also use collection.ToElements() or collection.ToElementIds() to convert the collection to a list of elements or Ids respectfully.)
If you look at the FilteredElementCollector class, you’ll see that it’s not a list but a collection (enumerable). There is no enumerable wrapper in Dynamo, so the elements don’t get translated from the collector.