# Revit API\_getting the Doors from Room with intersection

**URL:** <https://forum.dynamobim.com/t/revit-api-getting-the-doors-from-room-with-intersection/94303>\
**Category:** Revit\
**Tags:** api\
**Created:** [October 5, 2023, 5:57am UTC](https://forum.dynamobim.com/t/revit-api-getting-the-doors-from-room-with-intersection/94303 "2023-10-05T05:57:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmark](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jmark](https://forum.dynamobim.com/u/jmark)\
**Post date:** [October 5, 2023, 5:57am UTC](https://forum.dynamobim.com/t/revit-api-getting-the-doors-from-room-with-intersection/94303/1 "2023-10-05T05:57:00Z")

</div>

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](https://discourse.pyrevitlabs.io/) 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.

```auto
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))

```

---

<div class="post-metadata">

**Author:** ![thanhdatp297GRTHP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thanhdatp297grthp/32/167370_2.png) [@thanhdatp297GRTHP](https://forum.dynamobim.com/u/thanhdatp297GRTHP)\
**Post date:** [October 5, 2023, 9:58am UTC](https://forum.dynamobim.com/t/revit-api-getting-the-doors-from-room-with-intersection/94303/2 "2023-10-05T09:58:20Z")

</div>

I don’t think door 's location is LocationCurve.  
door.Location alway return a XYZ (a point), for that reason: “`isinstance(door_location, LocationCurve): = Flase`” and then nothing appended to your list.

The easiest you just try to remove 2 row

```auto
" if isinstance(door_location, LocationCurve):
        door_curve = door_location.Curve"

```

from your code, change `door_curve` in `intersection_result = curve.Intersect(door_curve)` to `door_location` and it will work

---

<div class="post-metadata">

**Author:** ![jmark](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jmark](https://forum.dynamobim.com/u/jmark)\
**Post date:** [October 6, 2023, 1:02am UTC](https://forum.dynamobim.com/t/revit-api-getting-the-doors-from-room-with-intersection/94303/3 "2023-10-06T01:02:02Z")

</div>

hi @thanhdatp297GRTHP thanks for looking, tried your suggestion but it’s giving me this

`TypeError: expected Curve, got LocationPoint`

---

<div class="post-metadata">

**Author:** ![thanhdatp297GRTHP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thanhdatp297grthp/32/167370_2.png) [@thanhdatp297GRTHP](https://forum.dynamobim.com/u/thanhdatp297GRTHP)\
**Post date:** [October 6, 2023, 3:59am UTC](https://forum.dynamobim.com/t/revit-api-getting-the-doors-from-room-with-intersection/94303/4 "2023-10-06T03:59:09Z")

</div>

> [@jmark](#):
>
> `LocationCurve`

You can try an other way, use both property Fromroom and Toroom

> **[FromRoom Property](https://www.revitapidocs.com/2022/d6658841-da29-ead4-049b-3036cbd4951a.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

> **[ToRoom Property](https://www.revitapidocs.com/2022/939e9c7b-072a-7be9-105f-64e1aa1f3a97.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

Creat a list of value Fromroom and Toroom for each Door and check is it contain with your room. If true, append this to your list

---

<div class="post-metadata">

**Author:** ![jmark](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jmark](https://forum.dynamobim.com/u/jmark)\
**Post date:** [October 6, 2023, 4:05am UTC](https://forum.dynamobim.com/t/revit-api-getting-the-doors-from-room-with-intersection/94303/5 "2023-10-06T04:05:39Z")

</div>

alright thanks, will try this on weekend and see where it’ll take me.
