Room.CenterBoundary equivalent

Hello,

I want to use the Room.CenterBoundary but with MEP Space.
Capture

I tried to get element geometry, then boundary but i can’t find the center boundary.

How could I do a work around to get this ?

Try this,

Capture

Hello Steven, thank you for your reply but in this projet we use MEP Spaces instead of Rooms.

So I managed to do it this way :

Is that giving you what you want? A bounding box would is just that a square box. Room.CenterBoundary is the center line of the rooms bounding elements and will hold true to the shape of the room.

I was thinking you could pull the rooms from the architecture model like this. (I think you need archi-lab and springs.nodes)

If what you are doing is giving you the results you need then please mark this post as solved.

Yes, thanks to the node “BoundingBox.PerimeterCurvesByNormal”.

I will mark it up.

Thank you !

Starting with Dynamo 2.6 (I believe) Space.CenterBoundary as well as others are included. However, I needed to replicate Space.Boundary node functionality with a Python script for backward compatibility. The heavy lifting in the script is done by GetBoundarySegments with the applicable SpatialElementBoundaryOption set.

# References
# https://forum.dynamobim.com/t/get-room-boundaries-as-lines/76635
# https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/3
# https://www.revitapidocs.com/2021.1/349e4292-28b6-cffa-e128-50ac5c90db36.htm

# Load the Python Standard and DesignScript Libraries
import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import System
from System import Array
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
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 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN[0]

# Place your code below this line
# Unwrap
spaces = UnwrapElement(dataEnteringNode)

# Arrays
curves = []
boundaries = []

# Boundary options for spaces
opt = SpatialElementBoundaryOptions()
# Set spatial boundary location option to 'Spacial element centerline.'
# Boundary location enumeration: https://www.revitapidocs.com/2021.1/349e4292-28b6-cffa-e128-50ac5c90db36.htm
# enumeration=[Finish,Center,CoreBoundary,CoreCenter]
opt.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center
# Iterate through every space and find boundary curves
for space in spaces:
	rvBoundary = space.GetBoundarySegments(opt) # Get space boundary
	dsBoundary = [] # A Dynamo list to hold the boundary per space remember it can be complex, with holes		
	for rvLoop in rvBoundary: # For each loop in the space boundary
		dsLoop = [] # A list to hold each space's loop
		for rvPiece in rvLoop:	# Retrieve each segment of the loop
			dsPiece = Revit.GeometryConversion.RevitToProtoCurve.ToProtoType(rvPiece.GetCurve(),True) # Read the segment as Curve and convert to Dynamo geometry
			dsLoop.append(dsPiece) # Add the piece to the Dynamo Loop
		dsBoundary.append(dsLoop) # Add the Dynamo Loop to the Dynamo Boundary
	curves.append(dsBoundary) # Add the Dynamo Boundary per space to the Curves list
	
# Iterate through list of curves and make polycurve
for curve in curves:
	boundaries.append(PolyCurve.ByJoinedCurves(curve[0]))

# Assign your output to the OUT variable.
OUT = boundaries

Fairly straight forward but a little tough to find guidance on mechanics to set the applicable SpatialElementBoundaryOption.

-Jake