import rhinoscriptsyntax as rs import random as ran #delelte all objects and start from scratch allobjs = rs.AllObjects() rs.DeleteObjects(allobjs) rs.EnableRedraw(False) # list of block #blocks = ["floor twisted tower", "floor commerz", "floor stern"] # #selected_block = ran.choice(blocks) #select random Block # #floor = rs.InsertBlock(selected_block, [0,0,0]) ## TWIST def make_paratower(insertion_point = [0,0,0]): rs.EnableRedraw(False) #uncomment to get a random number of floors #num = ran.randint(20,120) #numbers of floors #uncomment to pick a exact number of floord num = 25 #to use the same block for the whole tower if 1: blocks = ["floor twisted tower", "floor commerz", "floor stern"] #list of blocks selected_block = ran.choice(blocks) #select random block #selected_block = ["floor twisted tower"] highest_point = 0 last_angle = 0 #loop to twist for i in range(num): #variables for soft coding fl_height = 3.48 #height of the block/floor layer_point = "ceiling outline" x_c = insertion_point[0] #x-coordinate of insertion point y_c = insertion_point[1] #y-coordinate of insertion point f_th = 0.24 #thickness of foundation #uncomment if you want a random pick floor = rs.InsertBlock(selected_block, insertion_point) #THE DOUBLED FACADE #insert the needed facadeline if selected_block == "floor twisted tower": facadeline = rs.InsertBlock("floor twisted tower_facadeline", [x_c, y_c, 0]) if selected_block == "floor commerz": facadeline = rs.InsertBlock("floor commerz_facadeline", [x_c, y_c, 0]) if selected_block == "floor stern": facadeline = rs.InsertBlock("floor stern_facadeline", [x_c, y_c, 0]) #explode facadelines in order to use it for the facade exploded_objects = rs.ExplodeBlockInstance(facadeline) exploded_objects = list(exploded_objects) #SOLID FACADE #variables for decreasing the solid facade decreased_height = 0.05 #height that the facade will be decreased by fa_height = fl_height - (decreased_height*i) #facade hight decreasing by every level if fa_height < 0.1: #if the facade_height gets below 0.1 it will stay 0.1 fa_height = 0.1 #creating the solid facade path=rs.AddLine(insertion_point,[x_c,y_c,fa_height]) #direction to extrude sf_to_extrude = rs.ExtrudeCurve(exploded_objects, path) #extruded facade s_fa = "Tragende Wand" rs.ObjectLayer(sf_to_extrude, s_fa) #changing object layer #GLASS FACADE #variables for decreasing the glass facade fa_height_start = 0.1 #starting height of the glass facade increased_height = 0.05 #height that the facade will be increased by fa_height = fa_height_start + (increased_height*i) #facade hight decreasing by every level if fa_height > fl_height: #if the facade_height gets below 0.1 it will stay 0.1 fa_height = fl_height #offsetting the curve for the glass facade fa_th = 0.5 #distance between the facade layers offset_curves_s = [] layer_offs_c = "ceiling outline" for curve in exploded_objects: offset_curve_s = rs.OffsetCurve(curve, insertion_point, -fa_th) rs.ObjectLayer(offset_curve_s, layer_offs_c) if offset_curve_s: offset_curves_s.append(offset_curve_s) #creating the glass facade path=rs.AddLine(insertion_point,[x_c,y_c,fa_height]) #direction to extrude layer_path = "ceiling outline" rs.ObjectLayer(path, layer_path) gf_to_extrude = rs.ExtrudeCurve(offset_curve_s,path) #extruded facade g_fa = "glass" rs.ObjectLayer(gf_to_extrude, g_fa) #changing object layer #create list to work with objects_list = [floor,sf_to_extrude, gf_to_extrude] # move objects rs.MoveObjects(objects_list, [0, 0,fl_height* i]) #rotation floor and facadeline rs.AddPoint(insertion_point) #center of rotation disturb = 0.1 #disturb factor for rotation angle angle = -10 + ran.uniform(-disturb, disturb) #Rotation angle rs.RotateObjects(objects_list,insertion_point, angle*i) last_angle = angle*i #last rotation angle (to add the ceiling in the same angle as the last floor) #stufenweises scaling (1 to activate, 0 to deactivate) if 1: scale_factor = 1 #scale factor for the first block scale_decreased = 0.01 #scale factor, which decreases each block by this factor scale = scale_factor - (scale_decreased*i) min_scale = 0.5 if scale <= 0.5: print ("the loop stopped, the scale was to small") rs.DeleteObjects(objects_list) #delete last floor, otherwise it will add it to the loop without scaling it break #stop the loop if the scaling gets to small rs.ScaleObject(objects_list, insertion_point, [scale, scale, 1]) #scaling only in x and y-richtung, z-richtung stays the same rs.LayerVisible("ceiling outline", False) #hide the layer of the facadelines rs.EnableRedraw(True) para_tower_1 = make_paratower(insertion_point = [0,0,0])