import rhinoscriptsyntax as rs import random as ran # delete everything and start from scratch rs.DeleteObjects(rs.AllObjects()) ################################################################################ # Variables ################################################################################ thick = 0.18 # thickness of all slabs # stair values s_width = 2.4 # 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 thmax = 0.19 # maximum acceptable rise ################################################################################ # make_curved_podeststair(curve, th, tt, steps, thick, s_width, pod_l, DC, P, A) # # stair with landings and up and down changes along a curve ################################################################################ # Arguments / Variables: # curve = objectID of a curve # th = tritt hoehe / rise (float) # tt = tritt tiefe / tread depth (float) # steps = anzahl stufen / number of steps (int) # thick = thickness of stair (below tread) (float) # s_width = breite der stufen / stair width (float) # pod_l = podest laenge / depth of landing (float) # DC = direction change every DC steps (int) # P = podest / landing every P steps (int) # A = Antrittpodest / first landing, if 0 no landing is created (float) ################################################################################ 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): #switch=ran.randint(0,9) if(not(i%DC)): ##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)): ##P: Podest 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): ##P: Erstes Podest 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: add a lower edgepoint 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) ################################################################################ # Arguments / Variables: # returns list of lists: stairs (f_list, c_list, p_list, stair_l) ################################################################################ return(f_list, c_list, p_list, stair_l) ################################################################################ # set the stair parameters ################################################################################ th = 0.2 # initial rise value thmax = 0.18 # highest acceptable rise value tt = 0.3 # step size s_width = 1.4 # s_width = stair width pod_l = B # pod_l = depth of landing start = [pod_l,-(s_width*2+f_size/2), f_height+thick] # startpoint of stair ################################################################################ # calculate stair values ################################################################################ steps = int((hgt+thick)/th) if steps%2: steps = steps-1 th = (hgt+thick)/steps if(th>thmax): steps= steps+2 th = (hgt+thick)/steps ################################################################################ #loop to create staircase ################################################################################ stair_l = [] # list of stair objects for i in range(levels): start[2] = f_height+thick + i*(thick+hgt) # z-wert bei jeder Iteration neu gesetzt if i==levels-1: # letztes podest stair_l.append(make_podest([start[0]-pod_l, start[1]+s_width, start[2]-thick], pod_l, s_width, thick)) # sonderpodest else: stair_l.append(make_podest([start[0]-pod_l, start[1], start[2]-thick], pod_l, s_width*2, thick)) stair_l.append(make_stair(start, th, tt, int(steps/2), thick, s_width)) stair_l.append(make_podest([start[0]+(steps/2)*tt, start[1], start[2]+(steps/2)*th-thick], pod_l, s_width*2, thick)) stair_l.append(make_stair([start[0]+(steps/2)*tt, start[1]+s_width, start[2]+(steps/2)*th], th, -tt, int(steps/2), thick, s_width)) return(f_list, c_list, p_list, stair_l) ################################################################################ # Curve functions ################################################################################ #clover pattern with hack to prevent short-circuiting "nsc = no short-circuiting" def make_clover_nsc(p_num, radius=3, angle=45, translation=[0,0,0]): c_points =[] crv_angle=0 for i in range(p_num): nextpoint = rs.VectorRotate([radius,0,0],crv_angle, [0,0,1]) crv_angle=angle+crv_angle c_points.append(nextpoint) crv ="-_Polyline" for i in range(len(c_points)): crv += " {},{},{} _Mode=Arc".format(c_points[i][0], c_points[i][1],c_points[i][2]+i*0.0000001)# hack to prevent short-circuiting crv +=" _Enter" rs.Command(crv, False) curve=rs.FirstObject(False) rs.Command("-_ProjectToCPlane _selID {} _Enter _Yes _Enter".format(curve), False)# project curve to Cplane rs.MoveObject(curve, translation) return(curve) rs.EnableRedraw(False) ################################################################################ # Curved Stair functions ################################################################################ if 1: curve =rs.AddSpiral([0,0,0],[0,0,1], 2, turns=7, radius0=3, radius1=2) stair = make_curved_podeststair(curve,th=th, tt=tt, steps=240, thick=thick, s_width=s_width, pod_l=s_width/2, DC=300, P=300, A=2) stair2=rs.RotateObjects(stair, [0,0,0], 180, [0,0,1], True) rs.ScaleObject(stair2, [0,0,0], [2.5,2.5,1], False) stair3=rs.RotateObjects(stair, [0,0,0], 270, [0,0,1], True) rs.ScaleObject(stair3, [0,0,0], [0.5,0.5,1], False) if 1: curve =make_clover_nsc(24, 4, 80, (0,0,0)) stair = make_curved_podeststair(curve, th=th, tt=tt, steps=240, pod_l=s_width/2, thick=thick, s_width=s_width, DC=48, P=12, A=0) clover2=rs.CopyObject(stair, [0,0,10]) rs.ScaleObject(clover2, [0,0,0], [1.5,1.5,1], False) clover3= rs.CopyObject(stair, [0,0,25]) rs.ScaleObject(clover3, [0,0,0], [2,2,1], False) clover4= rs.CopyObject(stair, [0,0,45]) rs.ScaleObject(clover4, [0,0,0], [2.5,2.5,1], False) rs.EnableRedraw(True)