Revit Python Get Landing Area

Hi all!

I am trying to get the area of the stairs landings with python. I tried several ways and used examples I found on the web but none of them actualy works. Anyone can help?

Thanks in advance!

Post what you have done so far, and where it goes wrong.

1 Like

All of this script can effectively be done using Python, but this is the method Iā€™d follow. Landings are child elements of stairs, so you can get them using Dynamo node API or the following method to get landings from stairs:

#### GetStairsLandings

Stair landings.dyn (27.1 KB)

landings = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StairsLandings).WhereElementIsNotElementType().ToElements()

for landing in landings:
opt = Options()
geom = landing.get_Geometry(opt)
landing_FootPrint = (landing.GetFootprintBoundary)
#landing_FootPrint_Area = landing_FootPrint.Area
print(landing_FootPrint)
#print(landing_FootPrint_Area)

The line with # is the one not working. I can get the footprint of the landing but not the area

I already have a similar solution in dynamo. Now I need it in python.

The issue here is that there is no Area property for the footprint boundary (which is actually a list of Lines, that can be used like Curves also). Important to progressively view your code when dealing with geometry to know what types of objects are present at each step. GetFootprintBoundary is also a method so needs a pair of brackets afterwards.

The only way I could find to get the area of a landing with a single closed boundary was to use the IFC namespace which has a method for measuring the area of a list of curveloops, see below:

# Boilerplate text
import clr

import System
from System.Collections.Generic import List

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import *

clr.AddReference('RevitAPIIFC')
from Autodesk.Revit.DB.IFC import *

# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument

# Get all stair landings
landings = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StairsLandings).WhereElementIsNotElementType().ToElements()

# List of areas to append to
areas = []

# Iterate over landings, get area
for landing in landings:
	# Get the lines (curves) of the boundary
	opt    = Options()
	geom   = landing.get_Geometry(opt)
	curves = landing.GetFootprintBoundary()
	# Build a curveloop from the curves
	curveloop = CurveLoop()
	for c in curves:
		curveloop.Append(c)
	# Make a list object for the curveloop
	curveloops = List[CurveLoop]()
	curveloops.Add(curveloop)
	# Use exporterIFCutils to measure curveloop area
	area = ExporterIFCUtils.ComputeAreaOfCurveLoops(curveloops)
	areas.append(area)

# Areas
OUT = areas
1 Like

Thank you very much Gavin! Thats it!

Because I am not using the script in dynamo I had to do some little changes to run it directly. I share the final script so other users can use.

import clr

import System
from System.Collections.Generic import List

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import *

clr.AddReference('RevitAPIIFC')
from Autodesk.Revit.DB.IFC import *

**app = __revit__.Application**
**uidoc = __revit__.ActiveUIDocument**
**doc = uidoc.Document**

# Get all stair landings
landings = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StairsLandings).WhereElementIsNotElementType().ToElements()

# List of areas to append to
areas = []

# Iterate over landings, get area
for landing in landings:
	# Get the lines (curves) of the boundary
	opt    = Options()
	geom   = landing.get_Geometry(opt)
	curves = landing.GetFootprintBoundary()
	# Build a curveloop from the curves
	curveloop = CurveLoop()
	for c in curves:
		curveloop.Append(c)
	# Make a list object for the curveloop
	curveloops = List[CurveLoop]()
	curveloops.Add(curveloop)
	# Use exporterIFCutils to measure curveloop area
	area = ExporterIFCUtils.ComputeAreaOfCurveLoops(curveloops)
	areas.append(area)

**print(areas)**