import rhinoscriptsyntax as rs import random as ran #delete everthing and start from scratch allobjs = rs.AllObjects() rs.DeleteObjects(allobjs) # 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 # 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) def make_box(insertion=[0, 0, 0], xsize=10, ysize=10, zsize=10): # create a box 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 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=0.7, 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 ########################################################################### # Building the Structure ########################################################################### f_list = [] # List of foundations c_list = [] # List of columns p_list = [] # List of plates w_list = [] # List of walls # layers rs.AddLayer("foundation") rs.LayerColor("foundation", (155, 48, 255)) rs.AddLayer("columns") rs.LayerColor("columns", (60, 220, 60)) rs.AddLayer("plates") rs.LayerColor("plates", (60, 60, 220)) rs.AddLayer("facade") rs.LayerColor("facade", (200, 60, 60)) rs.EnableRedraw(False) # Building each level of the domino structure for i in range(levels): center_pt[2] = f_height + i * (thick + hgt) level = f_height + thick + (i - 1) * (hgt + thick) # create foundations on the first level if i == 0: rs.CurrentLayer("foundation") f_list = make_foundations(A, f_size, f_height, xcol, ycol) else: rs.CurrentLayer("columns") c_list.extend(make_columns(A, level, thick, hgt, xcol, ycol)) # create floor plates rs.CurrentLayer("plates") p_list.append(make_box(center_pt, p_width, p_length, thick)) rs.CurrentLayer("facade") #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_geight/2 for the correct 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 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]) # Print results for debugging print(facade_2) print(f_list) print(c_list) print(p_list) print(w_list) print(facade_list) rs.EnableRedraw(True)