How to get the sub component of List of stairs


I found the python script in this forum but it works only for single stair.
Can anyone who good at python can suggest how to modify the script so it works for list of stair?
or any simple package recommended to do this task.

Can you paste the actual code rather than a screen grab?

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

clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

stairs = IN[0]

def isInstance(check):
if isinstance(check, (list)): return check
else: return [check]

def getRunsLandings(stair):
runs =
landings =
stair = isInstance(stair)
stair = UnwrapElement(stair)
for s in stair:
runids = s.GetStairsRuns()
landingids = s.GetStairsLandings()
for run in runids:
runs.append(doc.GetElement(run))
for landing in landingids:
landings.append(doc.GetElement(landing))
staircomps = [runs + landings]
return staircomps

OUT = map(getRunsLandings(stairs))

above is the actual code.

Hello @netinaiV49EE,

You can change the last line of code here to use a List Comprehension to get the result you are after :slight_smile:

This is basically running a For Loop inside a single line.

OUT = [getRunsLandings(stair) for stair in stairs]

Great, It works Thanks !!

1 Like