import Rhino.Geometry as rg import rhinoscriptsyntax as rs from math import * import random as ran rs.EnableRedraw(False) ### Delete everything and start from scratch rs.DeleteObjects(rs.AllObjects()) ### Variables t_area = 150000 # total area of building t_flr = 77 # total floors of building t_height = 314 # total height of building ### average measures pts = [] avg_flr_area = int(t_area / t_flr) avg_flr_height = int(t_height / t_flr) avg_flr_width = max(int(sqrt(avg_flr_area)), 50) # Ensure width is large enough ### pixel dimensions pixel_width = 2 pixel_height = avg_flr_height pixel_depth = 2 ### box_dimensions b_height = 4 b_width = 8 all_boxes = [] ### Terrace Setback setback_h = 2 setback_height = t_flr - b_height # Adjusted to ensure it works setback_width1 = 20 # Increased setback width setback_width2 = 20 # Debugging ranges #print("Setback X-Range:", list(range(-int(avg_flr_width / 2) + setback_width1, int(avg_flr_width / 2) - setback_width2))) # Counters for skipped points skipped_lower_points = 0 skipped_terrace_points = 0 ### create main building form for x in range(-int(avg_flr_width / 2), int(avg_flr_width / 2) + pixel_width, pixel_width): for y in range(-int(avg_flr_width / 2), int(avg_flr_width / 2) + pixel_width, pixel_width): for z in range(t_flr): ptz = z * pixel_height + pixel_height / 2 # Remove unnecessary central points if z < setback_height and x in range(-int(avg_flr_width / 2) + b_width, int(avg_flr_width / 2) + pixel_width - b_width) and y in range(-int(avg_flr_width / 2) + b_width, int(avg_flr_width / 2) + pixel_width - b_width): skipped_lower_points += 1 continue # # Remove the points of the top terrace x # elif z >= setback_height and x in range(-int(avg_flr_width / 2) + setback_width1, int(avg_flr_width / 2) - setback_width2) and y in range(-int(avg_flr_width / 2) + setback_width1, int(avg_flr_width / 2) - setback_width2): # #print("Skipping terrace point at (x={}, y={}, z={})".format(x, y, z)) # skipped_terrace_points += 1 # continue # # # Remove the points of the top terrace y # center_point = (x, y, ptz) # Center point for the box rs.AddPoint(center_point) # Add the center point to Rhino half_size = pixel_height / 2 corner1 = (x - half_size, y - half_size, ptz - half_size) corner2 = (x + half_size, y + half_size, ptz + half_size) my_box = rs.AddBox([ # Add the box to Rhino corner1, (corner2[0], corner1[1], corner1[2]), (corner2[0], corner2[1], corner1[2]), (corner1[0], corner2[1], corner1[2]), (corner1[0], corner1[1], corner2[2]), (corner2[0], corner1[1], corner2[2]), (corner2[0], corner2[1], corner2[2]), (corner1[0], corner2[1], corner2[2]) ]) all_boxes.append(my_box) my_line = rs.AddSpiral((0,0,0),(0,0,314),314/2,2,30,30) my_pts = rs.DivideCurve(my_line, 15, True, True) ### random pixel structure for b in all_boxes: rs.LineMaxDistanceTo(my_line, (my_pts)) if ran.randint(0,10) > 8: rs.DeleteObject(b) # Print summary of skipped points #print("Skipped lower floor points: {}".format(skipped_lower_points)) #print("Skipped terrace points: {}".format(skipped_terrace_points)) rs.EnableRedraw(True)