I am generating revit api stair but the height doesnt match the level that I am giving to the stair, any help?
thanks in advance
base_Level = levels[0]
next_level = levels[1]
TransactionManager.Instance.ForceCloseTransaction()
newStairsScope = StairsEditScope(doc, 'New Stairs')
newStairsId = newStairsScope.Start(base_Level.Id, next_level.Id)
t = Transaction(doc, 'set value')
t.Start()
newRun1 = Architecture.StairsRun.CreateSketchedRun(doc, newStairsId, 0, boundary_lines_1, riser_lines_1, path_lines_1)
t.Commit()
newStairsScope.Commit(StairsFailurePreprocessor())
1 Like
@igpema ,
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
check out this topic…
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)
[create stairs run]
corrected code
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persiste…
igpema
July 18, 2022, 4:13pm
3
thanks a lot for the reply @Draxl_Andreas , nevertheless your code generate same error than mine, there is no big differences between codes. Maybe I am overseen something (so I paste my code again). thanks in advance
class StairsFailurePreprocessor( IFailuresPreprocessor ):
def PreprocessFailures(self, failuresAccessor):
return FailureProcessingResult.Continue
TransactionManager.Instance.ForceCloseTransaction()
newStairsScope = StairsEditScope(doc, 'New Stairs')
newStairsId = newStairsScope.Start(base_Level.Id, next_level.Id)
trans = Transaction(doc, 'Stair Transaction')
trans.Start()
newRun1 = Architecture.StairsRun.CreateSketchedRun(doc, newStairsId, base_Level.Elevation, boundary_lines_1, riser_lines_1, path_lines_1)
trans.Commit()
trans.Dispose()
newStairsScope.Commit(a)
1 Like
igpema
July 19, 2022, 6:56am
4
Well I sorted it out by changing the height offset… no clue why it works but it does solve the problem…
class StairsFailurePreprocessor( IFailuresPreprocessor ):
def PreprocessFailures(self, failuresAccessor):
return FailureProcessingResult.Continue
TransactionManager.Instance.ForceCloseTransaction()
newStairsScope = StairsEditScope(doc, 'New Stairs')
newStairsId = newStairsScope.Start(base_Level.Id, next_level.Id)
trans = Transaction(doc, 'Stair Transaction')
trans.Start()
newRun1 = Architecture.StairsRun.CreateSketchedRun(doc, newStairsId, base_Level.Elevation, boundary_lines_1, riser_lines_1, path_lines_1)
stair = doc.GetElement(newStairsId)
o_ver = stair.LookupParameter("Versatz oben")
o_ver.Set(0.1)
trans.Commit()
trans.Dispose()
newStairsScope.Commit(a)
t = Transaction(doc, 'delete railings')
t.Start()
o_ver.Set(0.0)
t.Commit()
2 Likes