Hello
there is a missing parameter in the class PreprocessFailures function.
failuresAccessor without any other parameter becomes in fact the current instance of the class (which we must name “self” by convention in Python), you must therefore add a second parameter (whatever its name)
corrected code
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import StairsRun
class StairsFailurePreprocessor2( IFailuresPreprocessor ):
def PreprocessFailures(self, failuresAccessor):
return FailureProcessingResult.Continue
baseLevel = UnwrapElement(IN[0])
nextLevel = UnwrapElement(IN[1])
riserNum = IN[2]
TransactionManager.Instance.ForceCloseTransaction()
newStairsScope = StairsEditScope(doc, 'New Stairs')
newStairsId = newStairsScope.Start( baseLevel.Id, nextLevel.Id)
trans = Autodesk.Revit.DB.Transaction(doc, 'Stair Transaction')
trans.Start()
bdryCurves = list()
riserCurves = list()
pathCurves = list()
pt1 = XYZ(0,0,0)
pt2 = XYZ(15,0,0)
pt3 = XYZ(0,10,0)
pt4 = XYZ(15,10,0)
#boundary
bdryCurves.append(Line.CreateBound(pt1, pt2))
bdryCurves.append(Line.CreateBound(pt3, pt4))
#riser curves
for ii in range(riserNum):
end0 = (pt1 + pt2) * ii / float(riserNum - 1)
end1 = (pt3 + pt4) * ii / float(riserNum - 1)
end2 = XYZ(end1.X, 10, 0)
riserCurves.append(Line.CreateBound(end0,end2))
pathEnd0 = (pt1 + pt3) / 2.0
pathEnd1 = (pt2 + pt4) / 2.0
pathCurves.append(Line.CreateBound(pathEnd0, pathEnd1))
newRun1 = StairsRun.CreateSketchedRun(doc, newStairsId , baseLevel.Elevation , bdryCurves, riserCurves, pathCurves )
trans.Commit()
newStairsScope.Commit(StairsFailurePreprocessor2())
OUT = newRun1