import rhinoscriptsyntax as rs import random as ran rs.DeleteObjects(rs.AllObjects()) rs.EnableRedraw(False) # dom-ino variables: A = 5.0 # A = Module size distance between columns B = A/3 # B= distance of columns to end of plate thick = 0.2 # thickness of all slabs hgt = 2.7 # height of room xcol = 2 # columns in x direction ycol = 3 # columns in y direction levels = 6 # number of floor plates f_height = 0.5 # foundation height f_size = 0.8 # foundation edge size level= 0.7 # derived values: center_pt = [A*(xcol-1)/2, A*(ycol-1)/2, f_height] #insertion point of floor plate p_width = A*(xcol-1) + 2*B #width of floor plate (x) p_length = A*(ycol-1) + f_size #lenght of floor plate (y) # function to create box at centre 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.MoveObject(box, (-xsize/2, -ysize/2, 0)) rs.MoveObject(box, insertion) return(box) # function to create box at corner 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) # function to create a field of foundations def make_foundations(A=A, f_size=f_size, f_height=f_height, xcol=xcol, ycol=ycol): fns=[] for i in range(xcol): for j in range(ycol): fns.append(make_box([i*A,j*A,0], f_size, f_size, f_height)) return(fns) # function to create a field of columns def make_columns(A=A, level=level, thick=thick, hgt=hgt, xcol=xcol, ycol=ycol): cls=[] for i in range(xcol): for j in range(ycol): cls.append(make_box([i*A,j*A,level], thick, thick, hgt)) return(cls) #functions to make a the semi-circular terrace def make_arc(insertion, rad, thick, hgt, orientation): segs=[] segs.append(rs.AddArc([0,0,0], rad, 180)) segs.append(rs.AddArc([0,0,0], rad-thick, 180)) segs.append(rs.AddLine([rad,0,0], [rad-thick,0,0])) segs.append(rs.AddLine([-(rad-thick),0,0], [-rad,0,0])) crv=rs.JoinCurves(segs, delete_input=True) path=rs.AddLine([0,0,0], [0,0,hgt]) arc=rs.ExtrudeCurve(crv, path) rs.CapPlanarHoles(arc) rs.DeleteObject(crv) rs.DeleteObject(path) rs.RotateObject(arc, [0,0,0], orientation) rs.MoveObject(arc, insertion) return(arc) def make_terrace(A=A, level=level, thick=thick, hgt=hgt, xcol=xcol, ycol=ycol): cls=[] for i in range(xcol-1): for j in range(ycol-1): ori = ran.randint(0,6) if ori < 4 : orientation = ori*90 cls.append(make_arc([i*A+A/2, j*A+A/2, level], A/3, thick, hgt, orientation)) return(cls) # function to create stairs def make_stair(start, th, tt, steps, thick, s_width): pointlist = [start] for i in range(steps): # step up`th` pointlist.append([pointlist[-1][0], pointlist[-1][1], pointlist[-1][2] + th]) # step forward `tt` pointlist.append([pointlist[-1][0] + tt, pointlist[-1][1], pointlist[-1][2]]) # closing the outline pointlist.append([pointlist[-1][0], pointlist[-1][1], pointlist[-1][2] - thick]) pointlist.append([pointlist[0][0], pointlist[0][1], pointlist[0][2] - thick]) pointlist.append([pointlist[0][0], pointlist[0][1], pointlist[0][2]]) # 2D outline of the staircase from the points s_outline = rs.AddPolyline(pointlist) # extrude the outline to create the stair volume path = rs.AddLine(start, [start[0], start[1] + s_width, start[2]]) hull = rs.ExtrudeCurve(s_outline, path) # cap the ends of the extrusion rs.CapPlanarHoles(hull) rs.DeleteObject(s_outline) rs.DeleteObject(path) return hull # building dom-ino def make_domino(levels=levels, thick=thick, hgt=hgt, A=A, f_size=f_size, f_height=f_height, xcol=xcol, ycol=ycol): f_list=[] c_list=[] p_list=[] B = A/3 center_pt = [A*(xcol-1)/2, A*(ycol-1)/2, f_height] p_width = A*(xcol-1) + 2*B p_length = A*(ycol-1) + f_size for i in range(levels): center_pt[2] = f_height + i*(thick+hgt) level = f_height + thick + (i-1)*(hgt+thick) if i ==0: f_list = make_foundations(A, f_size, f_height, xcol, ycol) else: c_list.extend(make_columns(A, level, thick, hgt, xcol, ycol)) c_list.extend(make_terrace(A, level, thick, hgt, xcol, ycol)) p_list.append(make_box(center_pt, p_width, p_length, thick)) level = f_height + thick + (levels-1)*(hgt+thick) c_list.extend(make_terrace(A, level, thick, hgt, xcol, ycol)) #--------------------------------------------------------------------------------------------- # calculate stair values #--------------------------------------------------------------------------------------------- steps = int((hgt+thick)/ 0.17) if steps % 2: steps = steps - 1 th = (hgt+thick)/ steps if (th > 0.19): steps = steps + 2 th = (hgt + thick)/ steps #--------------------------------------------------------------------------------------------- # stair parameters #--------------------------------------------------------------------------------------------- tt = 0.3 # step size s_width = 1.2 # stair width pod_w = B # depth of landing start = [pod_w, -(s_width*2 + f_size/2), f_height + thick] # start point of stair # loop to create staircase stairs_l = [] for i in range (levels): start[2] = f_height + thick + i*(thick+hgt) #z_coord if i== levels-1: #last podest stairs_l.append(make_podest([start[0]-pod_w, start[1]+s_width, start[2]-thick], pod_w, s_width, thick)) #special podest else: stairs_l.append(make_podest([start[0]-pod_w, start[1], start[2]-thick], pod_w, s_width*2, thick)) stairs_l.append(make_stair(start, th, tt, int(steps/2), thick, s_width)) stairs_l.append(make_podest([start[0]+(steps/2)*tt, start[1], start[2]+(steps/2)*th-thick], pod_w, s_width*2, thick)) stairs_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, stairs_l) #facade variables for the box facade facadexsize = 0.2 facadeysize = 0.2 facadezsize = 0.2 dis = 0.4 vertical_spacing = 0.5 def make_boxy_facade(insertion=[0, 0, 0], facadexsize=facadexsize, facadeysize=facadeysize, facadezsize=facadeysize, xcol=xcol, ycol=ycol, dis=dis, vertical_spacing=vertical_spacing, levels=(levels-1), f_height=f_height, hgt=hgt, thick=thick): facade = [] # total height of the building (total height = number of levels * height per level) total_building_height = levels * hgt + +levels * thick # Set the starting X and Y positions for the facade x_start = center_pt[0] - p_width / 2 + f_height / 2 #update: added f_height/2 so that the facade doesn`t start in the liniar facade y_start = insertion[1] z_start = f_height+ f_height/2 #added f_height/2 for the correct the position of the facade(centered between the floorplates # number of horizontal facade lines (vertical elements) based on the total height of the building num_vertical_lines = int(total_building_height // vertical_spacing) # number of horizontal elements (spanning the width of the facade) num_horizontal_elements = int(p_width // dis) # loop to create horizontal facade elements for i in range(num_vertical_lines): height_offset = i * vertical_spacing + z_start # vertical offset for each horizontal line for j in range(num_horizontal_elements): x_position = j * dis + x_start # horizontal position aligned with the left edge of the building facade.append(make_box([x_position, y_start, height_offset], facadexsize, facadeysize, facadezsize)) return facade # call up of the functions for both sides of the dom ino structure(changed it to where the side with the steps is open bc it was difficult to adjust it) # facade_list = make_boxy_facade(insertion=[0,- f_size/2, 0]) facade_list = make_boxy_facade(insertion=[0, A * (ycol - 1)+ f_size/ 2, 0]) # facade variables for the vertical lines depth = 0.4 width = 0.1 dis = 0.4 vertical_spacing = 0.8 def make_facade_vlines(insertion=[0, 0, 0], depth=depth, width=width, height=(levels-1)*(hgt+thick), dist= dis): fc = [] num_facade_lines = int(p_length // dist) + 1 # offset in X direction (to position the facade relative to the columns) off=-B # loop through the number of facade lines and place them along the building length for i in range(num_facade_lines): # y position for each facade element, spacing them by 'dist' y_position = i * dist - f_size / 2 # add element to the list fc.append(make_box([insertion[0], y_position, f_height], depth, width, height)) return fc # call up of the functions for both sides of the dom ino structure facade_2 = make_facade_vlines(insertion= [-B, 0, 0]) facade_3 = make_facade_vlines(insertion= [A * (xcol - 1)+ B, 0, 0]) # four lists returned by make_domino are assigned directly to the variables f_list, c_list, p_list, and stairs_l (f_list, c_list, p_list, stairs_l) = make_domino(levels, thick, hgt, A, f_size, f_height, xcol, ycol) # layers rs.AddLayer("foundation") rs.LayerColor("foundation", (155, 48, 255)) rs.ObjectLayer(f_list, "foundation") rs.AddLayer("columns") rs.LayerColor("columns", (60, 220, 60)) rs.ObjectLayer(c_list, "columns") rs.AddLayer("plates") rs.LayerColor("plates", (60, 60, 220)) rs.ObjectLayer(p_list, "plates") rs.AddLayer("stairs") rs.LayerColor("stairs", (63, 191, 127)) rs.ObjectLayer(stairs_l, "stairs") rs.AddLayer("facade") rs.LayerColor("facade", (180, 0, 56)) rs.ObjectLayer(facade_2, "facade") rs.ObjectLayer(facade_3, "facade") rs.ObjectLayer(facade_list, "facade") rs.EnableRedraw(True)