# Get Room boundaries as Lines

**URL:** <https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635>\
**Category:** Developers\
**Created:** [May 17, 2022, 12:27pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635 "2022-05-17T12:27:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [May 17, 2022, 12:27pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/1 "2022-05-17T12:27:31Z")

</div>

Hello,

I get Code, to get Curves from my Room → RoomBounderies  
But it does not work: I use Revit 2023, CPython3

```auto
#This script was composed by Roberto Molinos - www.modelical.com

import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

# Import ToDSType(bool) extension method, not sure we need this
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Make sure the GeometryConversion utilities are accesible see https://github.com/DynamoDS/Dynamo/issues/1946
clr.ImportExtensions(Revit.GeometryConversion) 

# Unwrap
rooms = []
for i in IN[0]:
	rooms.append(UnwrapElement(i)) #This kind of opens the Revit element so it can be used by Dynamo Script
# Curve array
curves = []
# Boundary options for rooms
opt = SpatialElementBoundaryOptions()
# Iterate through every room
for room in rooms:
	if room.Area > 0: # Make sure it has positive Area, i.e is placed
		rvBoundary = room.GetBoundarySegments(opt) # Get room boundary
		dsBoundary = [] # A Dynamo list to hold the boundary per room, remember it can be complex, with holes		
		for rvLoop in rvBoundary: # For each loop in the room boundary
			dsLoop = [] # A list to hold each room's loop
			for rvPiece in rvLoop:	# Retrieve each segment of the loop
				dsPiece = Revit.GeometryConversion.RevitToProtoCurve.ToProtoType(rvPiece.Curve,True) # Read the segment as Curve and convert to Dynamo geometry
				dsLoop.append(dsPiece) # Add the piece to the Dynamo Loop
			dsBoundary.Add(dsLoop) # Add the Dynamo Loop to the Dynamo Boundary
		curves.append(dsBoundary) # Add the Dynamo Boundary per room to the Curves list
#Output
OUT = curves

```

I get an error ☹ is there a other way to get my room bounderies

currently i get it, but not in detail

 ![2022-05-17_14h26_47](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/b/fb906aeab06303427175254a5c20c322bf644629.png)  
 ![2022-05-17_14h26_58](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/e/1ee8415223d4bb977a5c88e86a7ee4e5e6b8559f.png)

KR

Andreas  
 ![2022-05-17_14h24_29](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/0/a099b71a8a7491a757e8f46f779c0799fddd04b7.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 17, 2022, 3:01pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/2 "2022-05-17T15:01:25Z")

</div>

The error says the object has no attribute `Curve`. The correct method is `GetCurve`.

> **[GetCurve Method](https://www.revitapidocs.com/2022/db394580-81c3-a25e-2562-707deefcd0e0.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [May 17, 2022, 3:08pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/3 "2022-05-17T15:08:40Z")

</div>

```auto
dsPiece = Revit.GeometryConversion.RevitToProtoCurve.ToProtoType(rvPiece.GetCurve,True)

```

so the error remains, i have to more to access correct method @Nick_Boyts ?

can i learn from that:

```auto
public void GetInfo_BoundarySegment(Room room)
{
   IList<IList<Autodesk.Revit.DB.BoundarySegment>> segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions());

   if (null != segments) //the room may not be bound
   {
      string message = "BoundarySegment";
      foreach (IList<Autodesk.Revit.DB.BoundarySegment> segmentList in segments)
      {
         foreach (Autodesk.Revit.DB.BoundarySegment boundarySegment in segmentList)
         {

            // Get curve start point
            message += "\nCurve start point: (" + boundarySegment.GetCurve().GetEndPoint(0).X + ","
                           + boundarySegment.GetCurve().GetEndPoint(0).Y + "," +
                          boundarySegment.GetCurve().GetEndPoint(0).Z + ")";
            // Get curve end point
            message += ";\nCurve end point: (" + boundarySegment.GetCurve().GetEndPoint(1).X + ","
                 + boundarySegment.GetCurve().GetEndPoint(1).Y + "," +
                 boundarySegment.GetCurve().GetEndPoint(1).Z + ")";
            // Get document path name
            message += ";\nDocument path name: " + room.Document.PathName;
            // Get boundary segment element name
            if (boundarySegment.ElementId != ElementId.InvalidElementId)
            {
               message += ";\nElement name: " + room.Document.GetElement(boundarySegment.ElementId).Name;
            }
         }
      }
      TaskDialog.Show("Revit",message);
   }
}

```

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 17, 2022, 3:10pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/4 "2022-05-17T15:10:01Z")

</div>

The same error? Or a new one? You do need to match the method exactly which means it should be `GetCurve()`.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [May 17, 2022, 3:10pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/5 "2022-05-17T15:10:53Z")

</div>

![2022-05-17_17h10_41](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/f/5f4ef6dd7088bc3dad09b1cb8ce4bab8be2f9ead.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 17, 2022, 3:13pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/6 "2022-05-17T15:13:07Z")

</div>

Now it’s saying there’s an issue with the `ToProtoType` method you’re using. Did you include the parenthesis on `GetCurve()`?

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [May 17, 2022, 3:19pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/7 "2022-05-17T15:19:11Z")

</div>

there are seviral ways 🙂 @Nick_Boyts

```auto
dsPiece = Revit.GeometryConversion.RevitToProtoGetCurve().ToProtoType(rvPiece.Curve,True)

```

```auto
dsPiece = Revit.GeometryConversion.RevitToProtoCurve.ToProtoType(rvPiece.GetCurve(),True)

```

i think it is more than copy paste

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 17, 2022, 3:22pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/8 "2022-05-17T15:22:21Z")

</div>

> [@Draxl\_Andreas](#):
>
> `dsPiece = Revit.GeometryConversion.RevitToProtoCurve.ToProtoType(rvPiece.GetCurve(),True)`

The latter is what you want. The `GetCurve()` method is for getting the underlying curve from the `BoundarySegment`. The method for conversion is `RevitToProtoCurve`.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [May 17, 2022, 3:37pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/9 "2022-05-17T15:37:41Z")

</div>

@Nick_Boyts

I understand the way it looping thrue my bounderies to get curve.  
1.) it filterd the rooms  
2.) getting the bounderies  
3.) converting it to curves  
4.) giving it to the basked

… i got it: there was also `add and not append `

 ![2022-05-17_17h36_14](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/4/84dda92664cb007b97ca7092b3be8489c2f31e94.png)

---

<div class="post-metadata">

**Author:** ![daniel82KGE](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@daniel82KGE](https://forum.dynamobim.com/u/daniel82KGE)\
**Post date:** [February 17, 2023, 2:13pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/10 "2023-02-17T14:13:30Z")

</div>

Hi Andreas,  
Is it possible to complete the script for getting the bounding box, all 3D lines of the room or the space.  
Daniel OLIVES  
Lyon-FRANCE

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [February 17, 2023, 2:17pm UTC](https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635/11 "2023-02-17T14:17:02Z")

</div>

@daniel82KGE ,

i suggest start a new topic
