import rhinoscriptsyntax as rs import scriptcontext as sc import random as ran allobjs = rs.AllObjects() rs.DeleteObjects(allobjs) # 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 thick = 0.18 # thickness of all slabs ################################################################################ # 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=800, 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) #rs.AddCurve([[0,0,0], [70,50,50], [180,230,100], [50,280, 75], [0,150,50], [-50,280,75], [-180,230,100], [-70,50,50],[0,0,0]],2) leaf1 = 2 # biggest leaf – Divisor leaf2 = 3 # middle leaf – Divisor leaf3 = 4 # smallest leaf – Divisor if 1: curve1 =rs.AddCurve([[0,0,0], [35/leaf1,25/leaf1,25/leaf1], [90/leaf1,115/leaf1,50/leaf1], [25/leaf1,140/leaf1, 37.5/leaf1], [0,75/leaf1,50/leaf1], [-25/leaf1,140/leaf1,37.5/leaf1], [-90/leaf1,115/leaf1,50/leaf1], [-35/leaf1,25/leaf1,25/leaf1],[0,0,0]],2) curve2 =rs.AddCurve([[0,0,0], [35/leaf2,25/leaf2,25/leaf2], [90/leaf2,115/leaf2,50/leaf2], [25/leaf2,140/leaf2, 37.5/leaf2], [0,75/leaf2,50/leaf2], [-25/leaf2,140/leaf2,37.5/leaf2], [-90/leaf2,115/leaf2,50/leaf2], [-35/leaf2,25/leaf2,25/leaf2],[0,0,0]],2) curve3 =rs.AddCurve([[0,0,0], [35/leaf3,25/leaf3,25/leaf3], [90/leaf3,115/leaf3,50/leaf3], [25/leaf3,140/leaf3, 37.5/leaf3], [0,75/leaf3,50/leaf3], [-25/leaf3,140/leaf3,37.5/leaf3], [-90/leaf3,115/leaf3,50/leaf3], [-35/leaf3,25/leaf3,25/leaf3],[0,0,0]],2) stair1 = make_curved_podeststair(curve1, th=th,tt=tt, steps=480, pod_l=pod_l, thick=0.5, s_width=s_width, DC=20, P=12, A=1.0) rs.RotateObject(stair1, [0,0,0], 120, None, True) rs.RotateObject(stair1, [0,0,0], 240, None, True) stair2 = make_curved_podeststair(curve2, th=th,tt=tt, steps=300, pod_l=pod_l, thick=0.5, s_width=s_width, DC=20, P=12, A=1.0) rs.RotateObject(stair2, [0,0,0], 20, None, False) rs.RotateObject(stair2, [0,0,0], 120, None, True) rs.RotateObject(stair2, [0,0,0], 240, None, True) stair3 = make_curved_podeststair(curve3, th=th,tt=tt, steps=250, pod_l=pod_l, thick=0.5, s_width=s_width, DC=20, P=12, A=1.0) rs.RotateObject(stair3, [0,0,15], 50, None, False) rs.RotateObject(stair3, [0,0,15], 150, None, True) rs.RotateObject(stair3, [0,0,15], 270, None, True)