import rhinoscriptsyntax as rs import random as ran import fantastic_stairs_lib as fs def create_staircase( height, # Total height of the staircase th_num, # Stair height num_steps, # Number of steps in the staircase platform_heights, # List of platform heights (can be one or multiple heights) platform_radius, # Radius of each platform platform_thickness, # Thickness of the platforms hole_radius, # Radius of the central hole in each platform num_rod, # Number of rods in the upper part handrail_width, # Width of the handrail spiral_spacing, # Spacing between spirals in the handrail middle_radius, # Radius of the middle part column_radius, # Radius of the vertical columns base_radius, # Radius of the base cylinder rod_radius # Radius of the rods in the upper part ): rs.DeleteObjects(rs.AllObjects()) # Base Cylinder crl = rs.AddCircle([0, 0, 0], base_radius) rs.ExtrudeCurveStraight(crl, [0, 0, 0], [0, 0, height]) srf = rs.FirstObject(select=False) rs.CapPlanarHoles(srf) # Stair crv = rs.AddSpiral([0, 0, 0], [0, 0, 1], 0, spiral_spacing, 1) fs.make_curved_stair(crv, th=th_num, steps=num_steps) # Platforms and Handrails for platform_height in sorted(platform_heights): oc = rs.AddCircle([2, 0, platform_height], platform_radius) ic = rs.AddCircle([0, 0, platform_height], hole_radius) oc_pl = rs.ExtrudeCurveStraight(oc, [0, 0, platform_height], [0, 0, platform_height + platform_thickness]) ic_pl = rs.ExtrudeCurveStraight(ic, [0, 0, platform_height], [0, 0, platform_height + platform_thickness]) rs.CapPlanarHoles(oc_pl) rs.CapPlanarHoles(ic_pl) rs.BooleanDifference(oc_pl, ic_pl, delete_input=True) # Handrail for Platform handrail_curve = rs.AddCircle([0, 0, platform_height + platform_thickness], platform_radius) handrail_offset = rs.CopyObject(handrail_curve, [0, 0, 1.2]) if handrail_curve and handrail_offset: rs.AddLoftSrf([handrail_curve, handrail_offset]) # Upper Part u_circle_center = [0, 0, height - 4] u_circle_radius = 2.5 uc = rs.AddCircle(u_circle_center, u_circle_radius) pts = rs.DivideCurve(uc, num_rod) for i in range(len(pts)): start_point = pts[i] end_point = [start_point[0], start_point[1], start_point[2] + 0.5] rod_line = rs.AddLine(start_point, end_point) rs.AddPipe(rod_line, 0, rod_radius) top_circle = rs.AddCircle([u_circle_center[0], u_circle_center[1], u_circle_center[2] + 0.5], u_circle_radius) bottom_circle = rs.AddCircle(u_circle_center, u_circle_radius) h1_pipe = rs.AddPipe(top_circle, 0, rod_radius) h2_pipe = rs.AddPipe(bottom_circle, 0, rod_radius) # Pipe to the center center_point = [0, 0, height - 4] points_on_circle = rs.DivideCurve(uc, 6, create_points=True, return_points=True) for point in points_on_circle: rod_line = rs.AddLine(point, center_point) rs.AddPipe(rod_line, [0, 1], [0.08, 0.1]) # Middle Part m_circle_center = [-1, 0, height - 8] mc = rs.AddCircle(m_circle_center, middle_radius) rs.ExtrudeCurveStraight(mc, m_circle_center, [-1, 0, height - 7.5]) pts1 = rs.DivideCurve(mc, 8, create_points=True, return_points=True) for point in pts1: rod_line = rs.AddLine([0, 0, height - 8], [point[0], point[1], height - 8]) rs.AddPipe(rod_line, [0, 1], [0.15, 0.1]) # Columns for p in pts1: crv = rs.AddCurve([p, (p[0], p[1], 0)], 1) rs.AddPipe(crv, 0, column_radius) # Example usage create_staircase( height=33, th_num=0.176470588, num_steps=119, platform_heights=[10, 20.5, 30], platform_radius=5, platform_thickness=0.5, hole_radius=1.6, num_rod=40, handrail_width=5.686, spiral_spacing=8, middle_radius=3, column_radius=0.005, base_radius=0.5, rod_radius=0.05 )