import rhinoscriptsyntax as rs import random as ran # Cleanup and start from scratch rs.DeleteObjects(rs.AllObjects()) # Variables s_width = 3 # Stair total width pod_l = 1.8 # Depth of landing tt = 0.3 # Tread depth th = 0.17 # Initial rise setting thick = 0.4 # Thickness of stairs thmax = 0.19 # Maximum acceptable rise rs.EnableRedraw(False) def make_curved_podeststair(curve, th=th, tt=tt, steps=40, thick=thick, s_width=s_width, pod_l=s_width/2, DC=48, P=12, A=0): pts = [[0, 0, 0]] for i in range(1, steps): if not (i % DC): # Direction Change th = -th pts.append([pts[-1][0] + pod_l, pts[-1][1], pts[-1][2]]) pts.append(pts[-1]) pts.append([pts[-1][0] + tt, pts[-1][1], pts[-1][2]]) elif not (i % P): # Podest (Landing) pts.append([pts[-1][0] + pod_l, pts[-1][1], pts[-1][2]]) pts.append([pts[-1][0] + tt, pts[-1][1], pts[-1][2]]) elif i == 1 and A > 0: # First Landing pts.append([pts[-1][0] + A, pts[-1][1], pts[-1][2]]) pts.append([pts[-1][0], pts[-1][1], pts[-1][2] + th]) pts.append([pts[-1][0] + tt, pts[-1][1], pts[-1][2]]) else: # Regular Steps pts.append([pts[-1][0], pts[-1][1], pts[-1][2] + th]) pts.append([pts[-1][0] + tt, pts[-1][1], pts[-1][2]]) if th < 0: # Stair ends going down pts.append([pts[-1][0], pts[-1][1], pts[-1][2] + th]) return_list = [] for i in range(-1, -len(pts), -2): return_list.append((pts[i][0], pts[i][1], pts[i][2] - thick)) pts.extend(return_list) pts.append([pts[0][0], pts[0][1], pts[0][2] - thick]) pts.append(pts[0]) s_outline = rs.AddPolyline(pts) path = rs.AddLine(pts[0], [pts[0][0], pts[0][1] + s_width / 2, pts[0][2]]) shadow = rs.AddLine(pts[0], [return_list[0][0], return_list[0][1], pts[0][2]]) s_surf = rs.AddPlanarSrf(s_outline) rs.Command("_Flow _selID {} _Enter _selID {} _selID {} _Enter".format(s_surf[0], shadow, curve), False) profile = rs.FirstObject() stair = rs.OffsetSurface(profile, s_width / 4, both_sides=True, create_solid=True) rs.DeleteObjects([s_surf[0], shadow, curve, path, s_outline, profile]) return stair def make_clover(p_num, radius=3, angle=45, translation=[0, 0, 0]): c_points = [] cur_angle = 0 for i in range(p_num): cur_angle = angle + cur_angle nextpoint = rs.VectorRotate([radius, 0, 0], cur_angle, [0, 0, 1]) c_points.append(nextpoint) cmd = "-_Polyline" for i in range(len(c_points)): cmd += " {},{},{} _Mode=Arc".format(c_points[i][0], c_points[i][1], c_points[i][2]) cmd += " _Enter" rs.Command(cmd, False) curve = rs.FirstObject(False) rs.MoveObject(curve, translation) return curve def make_concentric_clover_stairs(center=[0, 0, 0], num_circles=10, radius_step=4): curves = [] for i in range(1, num_circles + 1): curve = make_clover(20, radius_step * i, 360 / (12 * i), translation=center) curves.append(curve) # Adjust parameters dynamically based on circle index th_dynamic = th + (i * 0.01) tt_dynamic = tt - (i * 0.005) steps_dynamic = 40 + (i * 10) pod_l_dynamic = pod_l + (i * 0.2) # Generate stairs for each curve make_curved_podeststair(curve, th=th_dynamic, tt=tt_dynamic, steps=steps_dynamic, pod_l=pod_l_dynamic, thick=thick, s_width=s_width, DC=(10 + i * 3), P=(5 + i * 2), A=0) # Generate the structure make_concentric_clover_stairs(center=[0, 0, 0], num_circles=10, radius_step=6) # Cleanup rs.Command("_SelCrv _Enter") curves = rs.SelectedObjects() rs.DeleteObjects(curves) rs.EnableRedraw(True)