Edges of rooms

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.

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

Try the room.boundaries node.

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.

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

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

Example1
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.

Hi @DENIS.REMESNIK

Try using OOTB nodes:

3 Likes

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?

On the picture in first post I show that room have this information, but I can’t take it.

This should give you, what you need:

You have to switch on 3D roomcalculation in Revit

2 Likes

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
Warn
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

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
2 Likes

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