import rhinoscriptsyntax as rs rs.EnableRedraw(False) allobjs = rs.AllObjects() rs.DeleteObjects(allobjs) #Stair parameters s_width = 1.2 # Stair total width pod_l = 1.8 # Landing depth tt = 0.3 # Step depth th = 0.17 # Step rise thick = 0.19 # Stair thickness #Rectangular spiral parameters turns = 8 # Number of turns start_length = 15 # Starting length of the rectangle #Function to create a rectangular spiral def create_rectangular_spiral(turns, start_length): pts = [] # Points for the spiral x, y = 0, 0 # Starting point current_length = start_length #Initial rectangle size for t in range(turns): #Create a rectangle for the current turn rect = [ [x, y, 0], # Bottom-left corner [x + current_length, y, 0], # Bottom-right corner [x + current_length, y + current_length, 0], # Top-right corner [x, y + current_length, 0], # Top-left corner [x, y, 0] # Back to Bottom-left corner ] # Add the rectangle points to the list pts.extend(rect[:-1]) # Avoid duplicating the starting point # Shrink the rectangle x += 1.5 # Move x inward (changed) y += 1.5 # Move y inward (changed) current_length -= 3 # Decrease size symmetrically (changed) # Stop if the rectangle becomes too small if current_length <= 0: break # Create the polyline from the points return rs.AddPolyline(pts) #Usage example rect_spiral = create_rectangular_spiral(turns=12, start_length=12) # Modified values #Function to generate the stairs along the curve def make_curved_podeststair(curve, th=th, tt=tt, steps=50, thick=thick, s_width=s_width, pod_l=s_width/2, DC=10, P=15, An=0): pts = [[0, 0, 0]] if th < 0 and An == 0: An = 0.25 # Changed steps -= 2 # Changed for i in range(1, steps + 1): if not (i % DC): #Direction change pts.append([pts[-1][0], pts[-1][1], pts[-1][2] + th]) pts.append([pts[-1][0] + tt, pts[-1][1], pts[-1][2]]) 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]]) th = -th elif i == 1: #First landing if An > 0: pts.append([pts[-1][0] + An, 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]]) elif i == steps: # Last landing pts.append([pts[-1][0], pts[-1][1], pts[-1][2] + th]) pts.append([pts[-1][0] + tt, pts[-1][1], pts[-1][2]]) elif not (i % P): # Podest pts.append([pts[-1][0], pts[-1][1], pts[-1][2] + th]) pts.append([pts[-1][0] + tt, pts[-1][1], pts[-1][2]]) 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]]) 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 downward 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) if An > 0: pts.append([pts[1][0] - tt, pts[1][1], pts[1][2] - thick]) 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 / 2, both_sides=True, create_solid=True) rs.DeleteObjects([s_surf[0], shadow, path, s_outline, profile]) return stair curve =rs.AddSpiral([0,0,0],[0,0,1], 0, turns=8, radius0=38, radius1=4) len_c= rs.CurveLength(curve) An=0 P=10 mods = (len_c+An) / (P*tt+pod_l + tt) steps = int(mods*P)+1 make_curved_podeststair(curve, steps=steps, pod_l=pod_l, DC=steps+1, P=P, An=An) i = 1 len_fromstart = An+P*tt+pod_l/2 while (len_fromstart <= len_c): point = rs.CurveArcLengthPoint(curve, len_fromstart) m_l=rs.AddLine(point, [point[0],point[1],i*P*th-thick]) rs.AddPipe(m_l,0,0.5) i = i+1 len_fromstart += P*tt+pod_l + tt rs.EnableRedraw(True)