# Edges of rooms

**URL:** <https://forum.dynamobim.com/t/edges-of-rooms/17497>\
**Category:** Developers\
**Tags:** revit, python, dynamo\
**Created:** [December 18, 2017, 1:08pm UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497 "2017-12-18T13:08:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DENIS.REMESNIK](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DENIS.REMESNIK](https://forum.dynamobim.com/u/DENIS.REMESNIK)\
**Post date:** [December 18, 2017, 1:08pm UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/1 "2017-12-18T13:08:28Z")

</div>

Good afternoon!

Task: I want to solve the problem with automatic placement of equipment in the room (in my case - lighting fixtures). For this, I need to know the coordinates of the room’s edges . For this I need to get:  
a) The lines of which consist of a room to further obtain the coordinates of the vertices of these lines. Or  
b) Coordinates of the room’s edges

Problem: using method of BoundarySegment I get only coordinates of the plane of the floor.  
Question: How can I get the coordinates of lines describing a 3D room?

P.S. In LookUP, I found where is located coordinates of the room’s edges, but I could not get them.

 ![Untitled](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/d/edd4f76ade0e4f4265762d799ca2310e1a71a030.png)

> import clr
> 
> # Import RevitAPI
> 
> clr.AddReference(“RevitAPI”)  
> import Autodesk  
> from Autodesk.Revit.DB import \*
> 
> # Import DocumentManager and TransactionManager
> 
> clr.AddReference(“RevitServices”)  
> import RevitServices  
> from RevitServices.Persistence import DocumentManager  
> from RevitServices.Transactions import TransactionManager
> 
> # Import ToDSType(bool) extension method
> 
> clr.AddReference(“RevitNodes”)  
> import Revit  
> clr.ImportExtensions(Revit.Elements)  
> clr.ImportExtensions(Revit.GeometryConversion)
> 
> import clr  
> clr.AddReference(‘ProtoGeometry’)  
> from Autodesk.DesignScript.Geometry import \*
> 
> #The input to this node will be stored in the IN[0] variable.
> 
> doc = DocumentManager.Instance.CurrentDBDocument  
> app = DocumentManager.Instance.CurrentUIApplication.Application
> 
> appversion = app.VersionNumber
> 
> rooms =   
> boundaries =
> 
> collector = FilteredElementCollector(doc)  
> collector.OfCategory(BuiltInCategory.OST\_Rooms)
> 
> famtypeitr = collector.GetElementIdIterator()  
> famtypeitr.Reset()
> 
> output =
> 
> for item in famtypeitr:  
> elmID = item  
> eleminst = doc.GetElement(elmID)
> 
> #print eleminst  
> if eleminst.Area \> 0:  
> room = eleminst
> 
> ```
> boptions = Autodesk.Revit.DB.SpatialElementBoundaryOptions()
> boundsegs = room.GetBoundarySegments(boptions)
> boundcurves = []
> if app.VersionNumber == 2016:
> for bound in boundsegs:
> crvs = []
> for seg in bound:
> crv = seg.Curve()
> crvs.append(Revit.GeometryConversion.RevitToProtoCurve.ToProtoType( crv, True ))
> boundcurves.append(crvs)
> else:
> for bound in boundsegs:
> crvs = []
> for seg in bound:
> crv = seg.GetCurve()
> crvs.append(Revit.GeometryConversion.RevitToProtoCurve.ToProtoType( crv, True ))
> boundcurves.append(crvs)			
> 
> rooms.append(room)
> boundaries.append(boundcurves)
> 
> ```
> 
> OUT = boundaries

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [December 18, 2017, 2:02pm UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/2 "2017-12-18T14:02:00Z")

</div>

Try the room.boundaries node.

---

<div class="post-metadata">

**Author:** ![DENIS.REMESNIK](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DENIS.REMESNIK](https://forum.dynamobim.com/u/DENIS.REMESNIK)\
**Post date:** [December 19, 2017, 5:28am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/3 "2017-12-19T05:28:41Z")

</div>

> [@jacob.small](#):
>
> room.boundaries

Hi Jacob!

1. Can you tell me where I can found this node?
2. I would prefer found solution by python code if it’s possible.

Thnx for your reply.

---

<div class="post-metadata">

**Author:** ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)\
**Post date:** [December 19, 2017, 6:00am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/4 "2017-12-19T06:00:26Z")

</div>

@DENIS.REMESNIK Room.Boundaries is a node in the Clockwork package and the node does use Python 🙂

---

<div class="post-metadata">

**Author:** ![DENIS.REMESNIK](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DENIS.REMESNIK](https://forum.dynamobim.com/u/DENIS.REMESNIK)\
**Post date:** [December 19, 2017, 6:21am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/5 "2017-12-19T06:21:39Z")

</div>

Thank you a lot! I found this node but problem still unsolved.  
In this node used the same method and consequently - same result.

![Example1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/7/479b2ae0cf25d4c68510757cc8731e3173a63a65.png)  
May be somebody know how I can take directly edges from each room?  
As I show above - I can found this information in revit LookUp but I can’t take it in Dynamo.

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [December 19, 2017, 6:30am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/6 "2017-12-19T06:30:23Z")

</div>

Hi @DENIS.REMESNIK

> [@DENIS.REMESNIK](#):
>
> May be somebody know how I can take directly edges from each room?

Try using OOTB nodes:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/a/daf3bccf736597744677d9b26de2af4512bb3d1c.png)

---

<div class="post-metadata">

**Author:** ![DENIS.REMESNIK](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DENIS.REMESNIK](https://forum.dynamobim.com/u/DENIS.REMESNIK)\
**Post date:** [December 20, 2017, 8:19am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/7 "2017-12-20T08:19:09Z")

</div>

HI Kulkul,

Unfortunately it’s doesn’t work.  
When we use Boundary method - we can take information only about 2D edges - like you show above.  
But for my goals I should know coordinate all edges of room and after that find the coordinates of the ceiling plane  
For example: Square (2D object) consist of 4 edges, but cube (3D object) - 12. And boundary method take room like a square and we take only 4 edges, but I need all 12.  
Or can we take information about coordinate of geometric vertex?  
 ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/8/6/86fef377f92c293b20bf8fa443a9fa82204927fe.png)  
On the picture in first post I show that room have this information, but I can’t take it.

---

<div class="post-metadata">

**Author:** ![Johannes\_Meiners](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/johannes_meiners/32/9156_2.png) [@Johannes\_Meiners](https://forum.dynamobim.com/u/Johannes_Meiners)\
**Post date:** [December 20, 2017, 9:07am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/8 "2017-12-20T09:07:46Z")

</div>

This should give you, what you need:

 ![3D-Raum](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/a/9a4560bf0c8f2b569f6af4110270766209e0097d.png)

You have to switch on 3D roomcalculation in Revit

---

<div class="post-metadata">

**Author:** ![DENIS.REMESNIK](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DENIS.REMESNIK](https://forum.dynamobim.com/u/DENIS.REMESNIK)\
**Post date:** [December 20, 2017, 9:19am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/9 "2017-12-20T09:19:37Z")

</div>

Yes - it’s really what I want. Thank you!  
But it’s not a final solve. I want make it in Python and in this case I have some problem - may be somebody can help me with it:  
I take solid but I can’t take information about Edges and Faces but in RevitAPI it’s possible according:  
[http://www.revitapidocs.com/2017.1/ed60d240-5dac-cd79-82fc-7ef5b8577301.htm](http://www.revitapidocs.com/2017.1/ed60d240-5dac-cd79-82fc-7ef5b8577301.htm)  
 ![Warn](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/0/4006bc764f38cf7685889876c93e889aac48c4f1.png)  
My code below:

```
import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB import Parameter
import System

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

edges = [r.ClosedShell.Edges for r in FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms) if r.Area > 0]

OUT = edges
```

---

<div class="post-metadata">

**Author:** ![alvpickmans](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alvpickmans/32/41236_2.png) [@alvpickmans](https://forum.dynamobim.com/u/alvpickmans)\
**Post date:** [December 20, 2017, 11:09am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/11 "2017-12-20T11:09:55Z")

</div>

You can first convert collected rooms to dynamo types (`ToDSType(True)`) and then use dynamo methods to get their geometry and edges.

```
[...]

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

geometries = [r.ToDSType(True).Geometry() for r in FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms) if r.Area > 0]

edges = []

for geo in geometries:
	edges.append( [g.Edges for g in geo])

OUT = edges
```

---

<div class="post-metadata">

**Author:** ![DENIS.REMESNIK](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DENIS.REMESNIK](https://forum.dynamobim.com/u/DENIS.REMESNIK)\
**Post date:** [December 20, 2017, 11:19am UTC](https://forum.dynamobim.com/t/edges-of-rooms/17497/12 "2017-12-20T11:19:38Z")

</div>

Thank you and thanks to everyone who helped to find a solution  
It’s really what I want!
