Hi, I have the following Grasshopper file with a python scripting component that generates a straight run stair. It takes 1) base and top levels, 2) input linecurve, 3) desired stair type and 4) target riser height. Following the SDK example, I can create a stair without any problems so long as it goes from level 0 to level 1. If I give an input curve and specify it going from level 1 to 2 for example, I will get an error:
Top elevation of the run should not be less that value of “Extend Below Base”.
In my code, I am specifying level 1 at 2000 as the base level. I set the ‘Relative Top Height’ parameter for stair-run object as 2000 because the stair must go from level 1 to level 2 (4000). I believe this value cannot be equal or less than the bottom level elevation and causes the error.
Does anyone know how to get around this? It seems like the script should not be so complicated for a creating a simple straight-run stair. I have another code that works fine for sketched stairs but am just puzzled why a straight run staircase isn’t straightforward to create. Should I just create all stairs with level 0 as the base level and then apply transformations to the stair later? This doesn’t seem very “revit-idiomatic”.
Here is a screenshot of Rhino and Grasshopper:
And the screenshot of the successfully created stair on level 0, but missing the stair that should start from level 1:
This is the snippet of the main function:
def create_straightrun_stairs(l_line, bot_level, top_level, tread_depth, num_risers):
# creStart stair editing session
with StairsEditScope(doc, 'New Stairs') as new_stairs_scope:
new_stair_id = new_stairs_scope.Start(bot_level.Id, top_level.Id)
#Set stair type
new_stair = doc.GetElement(new_stair_id)
new_stair.ChangeTypeId(stair_type.Id)
# Start transaction to edit stairs
with Transaction(doc, 'Add runs and landing') as stairs_trans:
stairs_trans.Start()
# Convert from Rhino to Revit geometry
rl_line = Convert.Geometry.GeometryEncoder.ToCurve(l_line)
new_run = Architecture.StairsRun.CreateStraightRun(doc, new_stair_id, rl_line, Architecture.StairsRunJustification.Center)
new_run.EndsWithRiser = True
# Edit stair run 'Relative Top Height' parameter
top_elev_param = new_run.get_Parameter(BuiltInParameter.STAIRS_RUN_TOP_ELEVATION)
if top_elev_param:
_height = top_level.Elevation - bot_level.Elevation # already in internal units so no need to convert
top_elev_param.Set(_height)
# Edit stair run properties
new_stair.ActualTreadDepth = mm_to_internal(tread_depth)
new_stair.DesiredRisersNumber = num_risers
stairs_trans.Commit()
new_stairs_scope.Commit(StairsFailurePreprocessor())
return new_run
I am using Revit 2022 with the latest Rhino.Inside and am attaching the Grasshopper file here
Bug.gh (25.5 KB)