# How to get the sub component of List of stairs

**URL:** <https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [October 16, 2020, 3:39am UTC](https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262 "2020-10-16T03:39:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![netinaiV49EE](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/netinaiv49ee/32/100455_2.png) [@netinaiV49EE](https://forum.dynamobim.com/u/netinaiV49EE)\
**Post date:** [October 16, 2020, 3:39am UTC](https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262/1 "2020-10-16T03:39:58Z")

</div>

![dynamo forum](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/1/01e3068a923932c97391b7885b435110b465cf98.png)  
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.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [October 16, 2020, 6:48am UTC](https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262/2 "2020-10-16T06:48:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![netinaiV49EE](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/netinaiv49ee/32/100455_2.png) [@netinaiV49EE](https://forum.dynamobim.com/u/netinaiV49EE)\
**Post date:** [October 16, 2020, 6:51am UTC](https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262/3 "2020-10-16T06:51:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![netinaiV49EE](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/netinaiv49ee/32/100455_2.png) [@netinaiV49EE](https://forum.dynamobim.com/u/netinaiV49EE)\
**Post date:** [October 16, 2020, 6:52am UTC](https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262/4 "2020-10-16T06:52:03Z")

</div>

above is the actual code.

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 16, 2020, 2:32pm UTC](https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262/5 "2020-10-16T14:32:20Z")

</div>

Hello @netinaiV49EE,

You can change the last line of code here to use a [List Comprehension](https://www.programiz.com/python-programming/list-comprehension) to get the result you are after 🙂

This is basically running a _For Loop_ inside a single line.

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

---

<div class="post-metadata">

**Author:** ![netinaiV49EE](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/netinaiv49ee/32/100455_2.png) [@netinaiV49EE](https://forum.dynamobim.com/u/netinaiV49EE)\
**Post date:** [October 18, 2020, 9:51am UTC](https://forum.dynamobim.com/t/how-to-get-the-sub-component-of-list-of-stairs/56262/6 "2020-10-18T09:51:29Z")

</div>

Great, It works Thanks !!
