Railings- Auto place by selecting surface


You need to do list management. So, first group the floors by level and flatten the list of levels, then change the old code to the new one. You already have the solution, you just have to put the pieces together.

import clr

import Autodesk
from Autodesk.Revit.DB import *

import Revit

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

# Place your code below this line.
# Get host curves.
def GetHostCurves(host):
    faceRef = HostObjectUtils.GetTopFaces(host)[0]
    face = floor.GetGeometryObjectFromReference(faceRef)
    curveLoops = face.GetEdgesAsCurveLoops()
    curveloopCurves = [[c.ToProtoType() for c in curveloop] for curveloop in curveLoops]
    return curveloopCurves    

# Get host curves by level.
allCurves = []
for level in floorsByLevel:
    curvesByLevel = []
    for floor in level:
        floorCurves = GetHostCurves(floor)

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

In the simplest way possible with selecting the face directly that works - the node “group curves” from Archi Lab is grouping the curves forming closed loops.Railings
And if you want to be able to feed the object itself you can filter the faces like that - the logic is

  1. Get the element’s faces
  2. Get their normals
  3. Check if the normal is almost equal to the Z vector (0,0,1)
    4.Filter those faces only (the ones facing up)
    railing.dyn (29.1 KB)
    If you want to be able to feed multiple levels at once you need some list managing:

    Note the levels set in the nodes’ inputs.
    railing.dyn (38.6 KB)

Thank you so much for everyone who replied, it seems that I have found out a solution. This is a combination of the feedback from everyone. I have attached the screenshot and file for everyone to use! (Version: Revit 2020)

Hope this helps. Create railing from surface (test).dyn (210.2 KB)

fencing excel.xlsx (10.5 KB)

dont mind the freezed nodes up top haha

final building with different slab openings and different slab heights


Viktor, thank you so much for the amazing feedback, I have gone and used some of these nodes in my final script. Thanks!

1 Like

Organon, thank you so much for the amazing feedback, I have gone and used your feedback in my final script, many thanks!

1 Like