import rhinoscriptsyntax as rs import random as ran import math rs.EnableRedraw(False) s_width = 2 # Width of the stair (consistent) pod_l = 1.8 # Length of each pod (step length) tt = 0.3 # Step depth (how much the stair moves along the x-direction) th = 0.17 # Height increment per step thick = 30 # Thickness of the stair turns = 8 # Number of turns in the spiral radius0 = 4 # Starting radius of the spiral radius1 = 70 # Ending radius of the spiral def make_curved_podeststair(curve, th=th, tt=tt, steps=40, thick=thick, s_width=s_width, pod_l=s_width/2, DC=12, P=12, An=0): pts = [[0,0,0]] if(th<0 and An==0): An=0.3 steps=steps-1 for i in range(1,steps+1): if(not(i%DC)): 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): 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): 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)): 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: 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: 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) import rhinoscriptsyntax as rs import random as ran import math rs.DeleteObjects(rs.AllObjects()) # Function to calculate the radius as the spiral grows outward def outward_spiral_radius(t, radius0=radius0, radius1=radius1): """ Calculate the radius for a point on the outward spiral. """ return radius0 + (radius1 - radius0) * t # Generate the outward spiral curve with constant step width curve_points = [] # Create points along the spiral curve for i in range(turns * 100): # 100 points per turn for smoothness t = i / (turns * 100) # Parameter t from 0 to 1 angle = t * 2 * math.pi * turns # Full circle times turns radius = outward_spiral_radius(t) # Adjust radius as it goes outward x = radius * math.cos(angle) # Using math.cos instead of rs.Cos y = radius * math.sin(angle) # Using math.sin instead of rs.Sin z = t # Increasing height as t goes curve_points.append([x, y, z]) # Create the spiral curve curve = rs.AddCurve(curve_points) len_c = rs.CurveLength(curve) An = 0 P = 10 mods = (len_c + An) / (P * tt + pod_l + tt) steps = int(mods * P) + 1 # Create the curved podest stair make_curved_podeststair(curve, steps=steps, pod_l=pod_l, DC=steps + 1, P=P, An=An) # Adjusting how the pipes are connected to each step: i = 1 len_fromstart = An + P * tt + pod_l / 2 while len_fromstart <= len_c: point = rs.CurveArcLengthPoint(curve, len_fromstart) # Move the height of the pipe to match the height of the stair at this point step_height = i * P * th - thick # Align pipe to the step height # Get the step point at that location step_point = [point[0], point[1], step_height] # Create the pipe at this step's location m_l = rs.AddLine(point, step_point) # Add the pipe (with a specific radius) rs.AddPipe(m_l, 0, 0.4) # Pipe radius 0.5 i = i + 1 len_fromstart += P * tt + pod_l + tt rs.EnableRedraw(True)