import rhinoscriptsyntax as rs import random as ran #cleanup and start from scratch rs.DeleteObjects(rs.AllObjects()) #variables # stair values s_width = 1 # 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 thick=0.4 # Arguments / Variables: # start = starting point # 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) rs.EnableRedraw(False) 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) def make_concentric_stairs(th=th, tt=tt, steps=100, thick=thick, s_width=s_width, pod_l=s_width/2, DC=40, P=20,center=[0,0,0], num_circles=15, radius_steps=1): crcls=[] angles=range(0, 360, 45) for i in range(num_circles): radius=radius_steps*(i + 1) crcls.append(rs.AddCircle(center, radius)) del crcls[0:3] for c in crcls: numb=crcls.index(c) dc_choice=numb*5+5 steps_number=int(400/((len(crcls)-numb))) stair=make_curved_podeststair(curve=c,th=th, tt=tt, steps=steps_number, thick=thick, s_width=s_width, pod_l=s_width/2, DC=dc_choice, P=40) angle=ran.choice(angles) rs.RotateObject(stair,center,angle) make_concentric_stairs() #cleanup rs.Command("_SelCrv _Enter") crvs=rs.SelectedObjects() rs.DeleteObjects(crvs) rs.EnableRedraw(True)