import rhinoscriptsyntax as rs import random as ran # delete everything and start from scratch allobjs = rs.AllObjects() rs.DeleteObjects(allobjs) # variables and values A = 5 # 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 = 4 # columns in x direction ycol = 8 # columns in y direction levels = 2 # number of levels f_height = 0.6 # foundation height f_size = 0.8 # foundation edge size num_facs = 250 # number of facade elements w_1 = 0.2 # min. width of elements w_2 = 0.8 # max. width of elements d_1 = 0.2 # mim. depth of elements d_2 = 0.8 # max. depth of elements h_1 = 1.0 # min. height of elements h_2 = (levels*(hgt+thick))+1.5 # max. height of elements rs.EnableRedraw(False) 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 # length of floor plate (y) # create a box def make_box(insertion, 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 foundations on the edges def make_foundations(A=5, f_size=0.8, f_height=0.8, xcol=4, ycol=6): fns=[] for i in range(xcol): for j in range(ycol): if i == 0 or i == xcol-1 or j == 0 or j == ycol-1: fns.append(make_box([i*A, j*A, 0], f_size, f_size, f_height)) return(fns) # function to create columns on the edges def make_columns(A=5, level=0.7, thick=0.2, hgt=3.0, xcol=4, ycol=6): cls = [] for i in range(xcol): for j in range(ycol): if i == 0 or i == xcol-1 or j == 0 or j == ycol-1: cls.append(make_box([i*A, j*A, level], thick, thick, hgt)) return cls # building dom-ino f_list=[] # list of foundation c_list=[] # list of columns p_list=[] # list of paltes s_list=[] # list of facade elements for i in range(levels + 1): level = f_height + i * (thick + hgt) if i == 0: f_list = make_foundations(A, f_size=f_size, f_height=f_height, xcol=xcol, ycol=ycol) if i < levels: c_list.extend(make_columns(A, level + thick, thick, hgt, xcol, ycol)) p_list.append(make_box([center_pt[0], center_pt[1], level], p_width, p_length, thick)) # create facade base def create_rectangle_around_plate(center, p_width, p_length): corner1 = [center[0] - p_width/2, center[1] - p_length/2, center[2]] corner2 = [center[0] + p_width/2, center[1] + p_length/2, center[2]] rectangle = rs.AddRectangle(corner1, p_width, p_length) return rectangle rectangle = create_rectangle_around_plate(center_pt, p_width, p_length) # facade def add_columns_around_rectangle(rectangle, num_facs=250): r_length = rs.CurveLength(rectangle) my_pts = rs.DivideCurve(rectangle, num_facs) for pt in my_pts: width = ran.uniform(w_1, w_2) depth = ran.uniform(d_1, d_2) height = ran.uniform(h_1, h_2) make_box([pt[0], pt[1], 0], width, depth, height) # builing facade add_columns_around_rectangle(rectangle, num_facs=250) rs.AddLayer("foundation") rs.LayerColor("foundation", (220,60,60)) 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("plate_outline") rs.LayerColor("plate_outline", (255, 0, 0)) rs.ObjectLayer(rectangle, "plate_outline") rs.AddLayer("facade") rs.LayerColor("facade", (0,255,255)) rs.ObjectLayer(s_list, "facade") rs.EnableRedraw(True)