Python and Stairs

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

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

I tried this code:

newStairsScope = StairsEditScope(doc, “New Stairs”)

newStairsId = newStairsScope.Start( getLevelId(int(levelBot)), getLevelId(int(levelTop)) )

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

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)
newLanding = StairsLanding.CreateSketchedLanding(doc, newStairsId, landingLoop, newRun1.TopElevation)


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

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

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.

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