I am currently trying to get the centerline(s) of a room (see picture attached). In addition, I would like to place family instances right on the intersection/edge points.
Does anybody know a smart and simple way to do so?
It seems kind of impossible to me, because you want te points in the middle of the room. Perhaps some genius can think of a solution :).
What i would suggest as a temporary fix would be to manually draw model lines in Revit and extract the points with dynamo. But that would still require much manual work.
for the centerlines you could try a code like this:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
#The inputs to this node will be stored as a list in the IN variables.
rooms = UnwrapElement(IN[0])
boundaries = []
options = SpatialElementBoundaryOptions()
options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center
for r in rooms:
lines = []
for loop in r.GetBoundarySegments(options):
for segment in loop:
c = segment.GetCurve()
p0 = c.GetEndPoint(0).ToPoint()
p1 = c.GetEndPoint(1).ToPoint()
#line = Line.CreateBound(p0,p1)
line = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(p0,p1)
lines.append(line)
boundaries.append(lines)
#Assign your output to the OUT variable.
OUT = boundaries
In the python node you just input the room list. Output would be a nested list of room boundaries (as dynamo lines) - a sublist per room.
Can’t have more time at the moment to look at the intersections part, but maybe you can work it out from here…
Hey, updated version… Think it’s mainly OOTB nodes and that particular one wasn’t needed…
It is based on walls being perpendicular (otherwise we get into Voroni kinds of solutions which I think will kill your PC). I have picked 3m as the maximum corridor width (it determines what is a cross wall and what is an end wall, this is fallible but mostly will work), you can vary this…
It is built for a single room right now, so you’d have to do some list level management to make it work for a whole building.
Ok, this is my work in progress: super simple cause Element.GetLocation should give you the centerline of the wall. Then just get the start point and end point and prune duplicates, check it out:
The next step would be to exclude start and endpoints of the lines that dont intersect with anything so you can throw away the points that are just on the beginning or end of a wall.
EDIT:
Ok, I think I got it this time!
I just used the Geometry.Intersect node with cross product lacing, flattened it out and filtered points and pruned again the duplicates.
Check it out: