import rhinoscriptsyntax as rs import random as ran rs.EnableRedraw(False) allobjs = rs.AllObjects() rs.DeleteObjects(allobjs) #------------------------------------------------------------------------------- # stair values #------------------------------------------------------------------------------- s_width = 1.2 # s_width = stair total width pod_l = 1.8 # pod_l = depth of landing tt = 0.3 # length of steps th = 0.17 # initial rise setting thick = 0.19 # maximum acceptable rise #------------------------------------------------------------------------------- # spiral values #------------------------------------------------------------------------------- turns = 10 radius0 = 25 radius1 = 5 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)): #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): #An: first Podest 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): #An: last 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]]) elif(not(i%P)): #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 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) 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) # Modify the spiral to start inside the radius rather than outside curve = rs.AddSpiral([0,0,0],[0,0,1], 0, turns=turns, radius0=radius1, radius1=radius0) 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 color_start = [0, 0, 255] # Light blue in RGB color_end = [173, 216, 230] # Blue in RGB num_pipes = int(len_c / (P*tt+pod_l+tt)) while (len_fromstart <= len_c): point = rs.CurveArcLengthPoint(curve, len_fromstart) m_l = rs.AddLine(point, [point[0],point[1],i*P*th-thick]) pipe = rs.AddPipe(m_l, 0, 0.5) # Calculate gradient color t = i / num_pipes r = int(color_start[0] + t * (color_end[0] - color_start[0])) g = int(color_start[1] + t * (color_end[1] - color_start[1])) b = int(color_start[2] + t * (color_end[2] - color_start[2])) rs.ObjectColor(pipe, [r, g, b]) i = i+1 len_fromstart += P*tt+pod_l + tt rs.DeleteObjects(curve)