import rhinoscriptsyntax as rs import math # Function to create a box def create_box(origin, width, depth, height): corners = [ origin, [origin[0] + width, origin[1], origin[2]], [origin[0] + width, origin[1] + depth, origin[2]], [origin[0], origin[1] + depth, origin[2]], [origin[0], origin[1], origin[2] + height], [origin[0] + width, origin[1], origin[2] + height], [origin[0] + width, origin[1] + depth, origin[2] + height], [origin[0], origin[1] + depth, origin[2] + height], ] return rs.AddBox(corners) # Function to create a custom panel def my_panel(points, scale): (P0, P1, P2, P3) = points rs.AddLine(P0, P2) d_cen1 = rs.VectorDivide(rs.VectorAdd(P0, P2), 2) d_cen2 = rs.VectorDivide(rs.VectorAdd(P1, P3), 2) center_pt = rs.VectorDivide(rs.VectorAdd(d_cen1, d_cen2), 2) vec1 = rs.VectorSubtract(P0, center_pt) vec2 = rs.VectorSubtract(center_pt, P3) normal = rs.VectorCrossProduct(vec1, vec2) u_normal = rs.VectorUnitize(normal) su_normal = rs.VectorScale(u_normal, scale) normal_pt = rs.VectorAdd(center_pt, su_normal) rs.AddSrfPt([P0, normal_pt, P1]) rs.AddSrfPt([P1, normal_pt, P2]) rs.AddSrfPt([P2, normal_pt, P3]) rs.AddSrfPt([P3, normal_pt, P0]) # Create tower base def create_tower_base(center, width, height): half_width = width / 2 origin = [center[0] - half_width, center[1] - half_width, center[2]] return create_box(origin, width, width, height) # Add perforations for facade def add_perforations(center, width, height): spacing = 2 hole_size = 1.5 num_rows = int(height / spacing) num_cols = int(width / spacing) holes = [] for row in range(num_rows): for col in range(num_cols): hole_x = center[0] - width / 2 + col * spacing hole_y = center[1] - width / 2 + row * spacing hole_origin = [hole_x, hole_y, center[2]] holes.append(create_box(hole_origin, hole_size, hole_size, height)) return holes # Create supports with stepped design on the sides of the tower def create_tower_supports(tower_center, tower_width, tower_height): base_support_width = 6 support_height_step = 5 num_support_steps = 10 supports = [] for step in range(num_support_steps): step_height = step * support_height_step step_width = base_support_width * (1 - step / num_support_steps) # Right support right_support_origin = [ tower_center[0] + tower_width / 2, tower_center[1] - step_width / 2, step_height, ] right_support = create_box(right_support_origin, step_width, step_width, support_height_step) supports.append(right_support) # Left support left_support_origin = [ tower_center[0] - tower_width / 2 - step_width, tower_center[1] - step_width / 2, step_height, ] left_support = create_box(left_support_origin, step_width, step_width, support_height_step) supports.append(left_support) return supports # Create roof panel def create_roof_panel(center, width, height): panel_points = [ [center[0] - width / 2, center[1] - width / 2, center[2]], [center[0] + width / 2, center[1] - width / 2, center[2]], [center[0] + width / 2, center[1] + width / 2, center[2]], [center[0] - width / 2, center[1] + width / 2, center[2]], ] my_panel(panel_points, scale=height) # Main script execution def main(): rs.DeleteObjects(rs.AllObjects()) tower_width = 20 tower_height = 80 facade_height = 60 roof_height = 20 center = [0, 0, 0] # Create tower tower = create_tower_base(center, tower_width, tower_height) # Add facade perforations perforations = add_perforations(center, tower_width, facade_height) # Create supports supports = create_tower_supports(center, tower_width, tower_height) # Add roof panel roof_center = [center[0], center[1], tower_height] create_roof_panel(roof_center, tower_width, roof_height) # Group all components rs.AddGroup("Tower") rs.AddObjectsToGroup([tower] + perforations + supports, "Tower") main()