Hey
I want to be able to filter all available “detail view” and “section” types in a project so I can select one of them in a userinterface.
I have no clue how to approach this.
Anyone?
I’ve made it till this point, but filtering out sections and detail views is still a question mark.
Hi @kboschJGDNZ
Give this a try?
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
detail_result = []
section_result = []
# Get all ViewFamilyType
view_family_types = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()
# Iterate through the collected ViewFamilyType elements
for view_family_type in view_family_types:
type_check = view_family_type.ViewFamily
type_name = view_family_type.LookupParameter('Type Name').AsValueString()
# Check the type
if type_check == ViewFamily.Detail:
detail_result.append([view_family_type,type_name])
elif type_check == ViewFamily.Section:
section_result.append([view_family_type,type_name])
else:
# Not one of the required types
pass
OUT = detail_result,section_result
1 Like
Thanks, that works perfectly:
1 Like