I get Code, to get Curves from my Room → RoomBounderies
But it does not work: I use Revit 2023, CPython3
#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
The latter is what you want. The GetCurve() method is for getting the underlying curve from the BoundarySegment. The method for conversion is RevitToProtoCurve.
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