But with Boolean=True it won’t work. It should find the elements in my Active View! (Yes I see my elements in the active view)
What am I doing wrong in the Python-script?
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
doc = DocumentManager.Instance.CurrentDBDocument
#doc.ActiveView.ToDSType(True)
active_view_only = IN[0]
# Vind elementen in document of in actieve View die voldoen aan een filter.
# Meer info over FilteredElementCollector
# https://dynamopythonprimer.gitbook.io/dynamo-python-primer/4-revit-specific-topics/fetching-revit-elements
# if True: Collect all instances of current View, False: entire document
if active_view_only is True:
alleElementen = FilteredElementCollector(doc, doc.ActiveView.Id)
else:
alleElementen = FilteredElementCollector(doc)
alleElementen.OfCategory(BuiltInCategory.OST_StructuralFoundation) # Refine filter: only BuiltInCategory Structural Foundations
alleElementen.WhereElementIsElementType() # Refine filter: only Types
alleElementen.ToElementIds() # Return Revit ElementIds
# Maak een lijst van alle gevonden paaltypen (= Family Types) waarvan de Family Name begint met '17' (volgens NL-SfB code)
alleFamilyNames = []
for ele in alleElementen:
familynaam = ele.FamilyName
if familynaam.startswith('17'):
alleFamilyNames.append(ele)
# Returnvalue: lijst met Family Types
OUT = alleFamilyNames
Sorry, but this does not work at all in Revit 2022 with CPython3
No errors, but it returns an empty list if Boolean is True
No errors, but it returns an empty list if Boolean is False
Thanks !!! This script works!
Is this because the difference of filtering instances “Symbol.FamilyName” instead of filtering Instance “Name”?
(Sorry for by bad English, I’m Dutch)