import rhinoscriptsyntax as rs import random as ran rs.DeleteObjects(rs.AllObjects()) #Variablen spw=5 #Spannweite B=spw/5 #Ueberstand dicke = 0.2 #Dicke h = 2 #Hoehe Raum xcol = 3 #Stuetzen in X richtung ycol = 6 #Stuetzen in Y richtung levels = 7 #Anzahl geschosse fund_h = 0.5 #Fund Hohe fund_a = 0.8 #Fund Kanten Lange #abgeleitete Variablen center_pt = [spw*(xcol-1)/2, spw*(ycol-1)/2, fund_h] #Mittelpunkt Platte p_breite = spw*(xcol-1)+2*B #Breite Platte p_lange = spw*(ycol-1) + fund_a #Laenge Platte #Funktionen ################################# #funktion fuer platte mittelpunkt def make_box(insertion=[0,0,0], xsize=10, ysize=10, zsize=10): corners = [[0,0,0], [xsize,0,0], [xsize,ysize,0], [0,ysize,0], [0,0,zsize], [xsize,0,zsize], [xsize,ysize,zsize], [0,ysize,zsize]] box = rs.AddBox(corners) rs.MoveObjects(box, (-xsize/2, -ysize/2, 0)) rs.MoveObject(box,insertion) return(box) #funktion fuer box an eckpunkt def make_podest(insertion=[0,0,0], xsize=10, ysize=10, zsize=10): corners = [[0,0,0], [xsize,0,0], [xsize,ysize,0], [0,ysize,0], [0,0,zsize], [xsize,0,zsize], [xsize,ysize,zsize], [0,ysize,zsize]] box = rs.AddBox(corners) rs.MoveObject(box,insertion) return(box) #funktion fuer verteilung Fund def make_foundations(spw=5.0,fund_a=0.8, fund_h=0.5, xcol=2, ycol=3): fns = [] for i in range (xcol): for j in range (ycol): fns.append(make_box([i*spw, j*spw, 0], fund_a, fund_a, fund_h)) return(fns) #funktion zur verteilung stuetzen def make_columns(spw=5.0, level=0.7, dicke=0.2, h=3.0, xcol=2, ycol=3): cls = [] for i in range (xcol): for j in range (ycol): cls.append (make_box([i*spw, j*spw, level], dicke, dicke, h)) return(cls) def make_terrace(spw=5.0, level=0.7, dicke=0.2, h=3.0, xcol=2, ycol=3): cls = [] for i in range (xcol-1): for j in range (ycol-1): ori = ran.randint(0,3) if ori<4: orientation = ori*90 return(cls) #funktion fuer stiege def make_stair(start, th, tt, steps, dicke, s_width): pointlist=[start] for i in range (steps): pointlist.append([pointlist[-1][0], pointlist[-1][1], pointlist[-1][2]+th]) pointlist.append([pointlist[-1][0]+tt, pointlist[-1][1], pointlist[-1][2]]) pointlist.append([pointlist[-1][0], pointlist[-1][1], pointlist[-1][2]-dicke]) pointlist.append([pointlist[0][0], pointlist[0][1], pointlist[0][2]-dicke]) pointlist.append([pointlist[0][0], pointlist[0][1], pointlist[0][2]]) s_outline = rs.AddPolyline(pointlist) path=rs.AddLine(start, [start[0], start[1]+s_width, start[2]]) hull = rs.ExtrudeCurve(s_outline, path) rs.CapPlanarHoles(hull) return(hull) rs.EnableRedraw(False) ############################################# #builing dom-ino def make_domino(spw=spw, B=B, dicke=dicke, h=h, levels=levels, xcol=xcol, ycol=ycol, fund_h=fund_h, fund_a=fund_a): f_list = [] #list of foundation c_list = [] #list of columns p_list = [] #list of plates for i in range(levels): center_pt[2] = fund_h + i*(dicke+h) level = fund_h + dicke + (i-1)*(h+dicke) if i == 0: f_list = make_foundations(spw, fund_a, fund_h, xcol, ycol) else: c_list.extend(make_columns(spw, level, dicke, h, xcol, ycol)) if(i%2): c_list.extend(make_terrace(spw, level, dicke, h, xcol, ycol)) p_list.append (make_box(center_pt, p_breite, p_lange, dicke)) level = fund_h + dicke + (levels-1)*(h+dicke) c_list.extend(make_terrace(spw, level, dicke, h, xcol, ycol)) ####################################### #berechnen stiegen parameter steps = int((h+dicke)/0.17) if steps%2: steps = steps-1 th= (h+dicke)/steps if (th>0.19): steps = steps+2 th= (h+dicke)/steps #Stiegen Parameter tt=0.3 #stiegen Auftritt s_width=1.2 #stiegen Breite pod_w=B #Podest Tiefe start = [pod_w,-(s_width*2+fund_a/2), fund_h+dicke] #anfangspunkt Stiege #loop um Stiegenhaus zu errichten stair_l = [] for i in range (levels): start[2]=fund_h+dicke + i*(dicke+h) #z-wert verschiebung um Geschoss if i==levels-1: #letztes podest stair_l.append(make_podest([start[0]-pod_w, start[1]+s_width, start[2]-dicke], pod_w, s_width, dicke)) else: stair_l.append(make_podest([start[0]-pod_w, start[1], start[2]-dicke], pod_w, s_width*2, dicke)) stair_l.append(make_stair(start, th, tt, int(steps/2), dicke, s_width)) stair_l.append(make_podest([start[0]+(steps/2)*tt, start[1], start[2]+(steps/2)*th-dicke], pod_w, s_width*2, dicke)) stair_l.append(make_stair([start[0]+(steps/2)*tt, start[1]+s_width, start[2]+(steps/2)*th], th, -tt, int(steps/2), dicke, s_width)) return(f_list, c_list, p_list, stair_l) (f_list, c_list, p_list, stair_l) = make_domino() rs.AddLayer("foundation") rs.LayerColor("foundation", (2,2,2)) rs.ObjectLayer(f_list, "foundation") rs.AddLayer("columns") rs.LayerColor("columns", (10,10,10)) rs.ObjectLayer(c_list, "columns") rs.AddLayer("plates") rs.LayerColor("plates", (92,87,81)) rs.ObjectLayer(p_list, "plates") rs.AddLayer("stairs") rs.LayerColor("stairs", (92,87,81)) rs.ObjectLayer(stair_l, "stairs") rs.EnableRedraw(True)