# Python and Stairs

**URL:** <https://forum.dynamobim.com/t/python-and-stairs/2136>\
**Category:** Packages\
**Created:** [September 10, 2015, 6:01pm UTC](https://forum.dynamobim.com/t/python-and-stairs/2136 "2015-09-10T18:01:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcelo\_Henrique\_Rib](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Marcelo\_Henrique\_Rib](https://forum.dynamobim.com/u/Marcelo_Henrique_Rib)\
**Post date:** [September 10, 2015, 6:01pm UTC](https://forum.dynamobim.com/t/python-and-stairs/2136/1 "2015-09-10T18:01:18Z")

</div>

Hi, i cant find a way to create a stair using only Python, the Stairs object dont have a create method nor the Autodesk.Revit.DB.Architecture.Stairs . So anyone have a clue how i can create a Stair using python ??

---

<div class="post-metadata">

**Author:** ![Peter\_Kompolschek](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@Peter\_Kompolschek](https://forum.dynamobim.com/u/Peter_Kompolschek)\
**Post date:** [September 11, 2015, 1:49am UTC](https://forum.dynamobim.com/t/python-and-stairs/2136/2 "2015-09-11T01:49:39Z")

</div>

one method described in revit api = StairsPath.Create method  
there you can find sample code too.

---

<div class="post-metadata">

**Author:** ![Marcelo\_Henrique\_Rib](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Marcelo\_Henrique\_Rib](https://forum.dynamobim.com/u/Marcelo_Henrique_Rib)\
**Post date:** [September 11, 2015, 6:20pm UTC](https://forum.dynamobim.com/t/python-and-stairs/2136/3 "2015-09-11T18:20:52Z")

</div>

I tried this code:

newStairsScope = StairsEditScope(doc, “New Stairs”)

newStairsId = newStairsScope.Start( getLevelId(int(levelBot)), getLevelId(int(levelTop)) )  
TransactionManager.Instance.EnsureInTransaction(doc)

bdryCurves = list()  
riserCurves = list()  
pathCurves = list()  
pnt1 = XYZ(0,0,0)  
pnt2 = XYZ(15,0,0)  
pnt3 = XYZ(0,10,0)  
pnt4 = XYZ(15,10,0)  
#boundary  
bdryCurves.append(Line.CreateBound(pnt1, pnt2))  
bdryCurves.append(Line.CreateBound(pnt3, pnt4))  
#riser curves  
riserNum = 20  
for ii in range(0,21):  
end0 = (pnt1 + pnt2) \* ii / float(riserNum)  
end1 = (pnt3 + pnt4) \* ii / float(riserNum)  
end2 = XYZ(end1.X,10,0)  
riserCurves.append(Line.CreateBound(end0,end2))

pathEnd0 = (pnt1 + pnt3) / 2.0  
pathEnd1 = (pnt2 + pnt4) / 2.0  
pathCurves.append(Line.CreateBound(pathEnd0, pathEnd1))

newRun1 = StairsRun.CreateSketchedRun(doc, newStairsId , getLevelBottom(int(levelBot)), bdryCurves, riserCurves,pathCurves )

locationLine = Line.CreateBound(XYZ(20, -5, newRun1.TopElevation), XYZ(35, -5, newRun1.TopElevation))

newRun2 = StairsRun.CreateStraightRun(doc, newStairsId, locationLine, StairsRunJustification.Center)  
newRun2.ActualRunWidth = 10

# Add a landing between the runs

landingLoop = CurveLoop()  
p1 = XYZ(15, 10, 0)  
p2 = XYZ(20, 10, 0)  
p3 = XYZ(20, -10, 0)  
p4 = XYZ(15, -10, 0)  
curve\_1 = Line.CreateBound(p1, p2)  
curve\_2 = Line.CreateBound(p2, p3)  
curve\_3 = Line.CreateBound(p3, p4)  
curve\_4 = Line.CreateBound(p4, p1)  
landingLoop.Append(curve\_1)  
landingLoop.Append(curve\_2)  
landingLoop.Append(curve\_3)  
landingLoop.Append(curve\_4)  
newLanding = StairsLanding.CreateSketchedLanding(doc, newStairsId, landingLoop, newRun1.TopElevation)

TransactionManager.Instance.TransactionTaskDone()

It makes the Stairs but it dont commit, it freezes on the Gray Edit mode, i tried to commit the newStairsScope.Commit but i cant find a way to pass the IFailurePreprocessor parameter to the commit. Anyone got a clue??

---

<div class="post-metadata">

**Author:** ![Marcelo\_Henrique\_Rib](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Marcelo\_Henrique\_Rib](https://forum.dynamobim.com/u/Marcelo_Henrique_Rib)\
**Post date:** [September 24, 2015, 5:41pm UTC](https://forum.dynamobim.com/t/python-and-stairs/2136/4 "2015-09-24T17:41:36Z")

</div>

If anyone got the same problem i just defined a class to extend IFailurePreprocessor on my python script just like this:

class StairsFailurePreprocessor( IFailuresPreprocessor ):  
def PreprocessFailures(failuresAccessor):  
return FailureProcessingResult.Continue

And then just used it like this:

a = StairsFailurePreprocessor()  
newStairsScope.Commit(a)

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [September 11, 2018, 8:37am UTC](https://forum.dynamobim.com/t/python-and-stairs/2136/6 "2018-09-11T08:37:22Z")

</div>

Please create a new thread instead of reviving a 3 year old one. You can link to this thread. Also, please show what you have done and maybe provide a copy of the Dynamo graph. Just saying you can’t get it to work will not be enough for anyone to understand your problem.

---

<div class="post-metadata">

**Author:** ![Thom](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thom/32/55621_2.png) [@Thom](https://forum.dynamobim.com/u/Thom)\
**Post date:** [September 11, 2018, 2:55pm UTC](https://forum.dynamobim.com/t/python-and-stairs/2136/7 "2018-09-11T14:55:23Z")

</div>

Yes you right. I created a new subjetct and I had my response. Thanks for helping.
