Hi All, I know there’s a node from Clockwork that gets the Door from Rooms but I would want to replicate it via Revit API as I would need to deploy it from other consultants via PyRevit and do something else with the parameters once I get the doors.
I have a code that gets the boundary of the room, the boundary of door instance and then find the doors via intersection. But for whatever reason it doesn’t work and it’s not giving me anything. Appreciate your help in advance.
from Autodesk.Revit.DB import *
from pyrevit import forms, revit
import clr
clr.AddReference("System")
from System.Collections.Generic import List
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app = __revit__.Application
selection = __revit__.ActiveUIDocument.Selection
active_view = doc.ActiveView
active_level = doc.ActiveView.GenLevel
with forms.WarningBar(title='Pick an element:'):
room_element = revit.pick_element()
element_category = room_element.Category.Name
if element_category != 'Rooms':
forms.alert('Please pick a Room', exitscript=True)
selected_room = doc.GetElement(room_element.Id)
rm_boundary_segments = selected_room.GetBoundarySegments(SpatialElementBoundaryOptions())
doors_in_room = FilteredElementCollector(doc, active_view.Id).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
rm_curve_lst = []
for segment in rm_boundary_segments:
for line in segment:
curve = line.GetCurve()
rm_curve_lst.append(curve)
door_lst = []
for door in doors_in_room:
door_location = door.Location
if isinstance(door_location, LocationCurve):
door_curve = door_location.Curve
for curve in rm_curve_lst:
intersection_result = curve.Intersect(door_curve)
if intersection_result:
door_lst.append(door)
print(len(door_lst))