import rhinoscriptsyntax as rs import math import flipped_classroom_lib as fc # Clear existing objects rs.DeleteObjects(rs.AllObjects()) center = (0, 0, 0) radius = 20 # Outer radius of the floor slab apartment core_radius = 8 # Radius of the central core ramp_radius, ramp_width = 10, 4 column_inset = 2 # Distance to move columns inward floor_height = 3 num_parking_floors, num_apartment_floors = 20, 30 num_transition_floors = 2 # Only 1 transition floor total_floors = num_parking_floors + num_transition_floors + num_apartment_floors column_radius, num_columns = 0.5, 12 # Radius and number of columns evenly distributed balcony_depth, balcony_thickness, balcony_inset = 10, 0.2, 4 # Distance balconies protrude outward, thickness of balcony slabs, alcony inset depth radius_car = radius + balcony_depth - balcony_inset # Function to create the central cylindrical core def add_central_core(): core_height = total_floors * floor_height # Full height of the tower core = rs.AddCylinder(center, core_height, core_radius, cap=True) return core # Function to create perimeter columns for apartments def add_apartment_columns(level_z): angle_step = 360 / num_columns columns = [] for i in range(num_columns): vec = [radius - column_inset, 0, 0] # Slightly inward from apartment floor slab rotated_vec = rs.VectorRotate(vec, angle_step * i, [0, 0, 1]) x, y, _ = rotated_vec col = rs.AddCylinder([x, y, level_z], floor_height, column_radius, cap=True) columns.append(col) return columns # Function to create columns for parking floors def add_parking_columns(level_z): angle_step = 360 / num_columns columns = [] for i in range(num_columns): vec = [radius_car - column_inset, 0, 0] # Parking columns further outward rotated_vec = rs.VectorRotate(vec, angle_step * i, [0, 0, 1]) x, y, _ = rotated_vec col = rs.AddCylinder([x, y, level_z], floor_height, column_radius, cap=True) columns.append(col) return columns # Function to create columns for transition floor def add_transition_columns(level_z): angle_step = 360 / num_columns columns = [] transition_height = floor_height * 2 # Columns for i in range(num_columns): vec = [radius - column_inset, 0, 0] # Same placement as apartment floors rotated_vec = rs.VectorRotate(vec, angle_step * i, [0, 0, 1]) x, y, _ = rotated_vec col = rs.AddCylinder([x, y, level_z], transition_height, column_radius, cap=True) columns.append(col) return columns # Function to create rotated circular balconies (pushed inward) def add_balconies(level_z): angle_step = 360 / num_columns rotation_offset = angle_step / 2 # Offset the balconies to avoid columns at their centers balconies = [] for i in range(num_columns): angle_rad = math.radians(angle_step * i + rotation_offset) x = (radius - balcony_inset + balcony_depth / 2) * math.cos(angle_rad) y = (radius - balcony_inset + balcony_depth / 2) * math.sin(angle_rad) balcony_center = [x, y, level_z] balcony_circle = rs.AddCircle(balcony_center, balcony_depth / 2) path = rs.AddLine([x, y, level_z], [x, y, level_z + balcony_thickness]) balcony = rs.ExtrudeCurve(balcony_circle, path) rs.CapPlanarHoles(balcony) balconies.append(balcony) rs.DeleteObjects([balcony_circle, path]) return balconies # Function to cut a hole in parking floors for the ramp def cut_ramp_hole(floor_slab, level_z): ramp_cylinder = rs.AddCylinder([0, 0, level_z], floor_height, ramp_radius + 0.5 , cap=False) if ramp_cylinder: floor_slab = rs.BooleanDifference(floor_slab, ramp_cylinder) rs.DeleteObject(ramp_cylinder) return floor_slab # Create the central core add_central_core() # Create parking floors with ramp holes for i in range(num_parking_floors): level_z = floor_height * i cir = rs.AddCircle(center, (radius_car)) ext = rs.ExtrudeCurveStraight(cir, center, [0, 0, 0.2]) rs.CapPlanarHoles(ext) rs.MoveObject(ext, [0, 0, level_z]) ext = cut_ramp_hole(ext, level_z) rs.DeleteObject(cir) if i < num_parking_floors - 1: add_parking_columns(level_z) # Create the transition floor transition_z = num_parking_floors * floor_height # Level of transition floor transition_height = floor_height * 2 # Twice the normal floor height # Create the floor slab for the transition floor transition_cir = rs.AddCircle(center, radius) transition_ext = rs.ExtrudeCurveStraight(transition_cir, center, [0, 0, 0.2]) rs.CapPlanarHoles(transition_ext) rs.MoveObject(transition_ext, [0, 0, transition_z]) rs.DeleteObject(transition_cir) # Add transition columns add_transition_columns(transition_z) # Create apartment floors with rotated circular balconies (pushed inward) for i in range(num_apartment_floors): level_z = floor_height * (i + num_parking_floors + num_transition_floors) cir = rs.AddCircle(center, radius) ext = rs.ExtrudeCurveStraight(cir, center, [0, 0, 0.2]) rs.CapPlanarHoles(ext) rs.MoveObject(ext, [0, 0, level_z]) rs.DeleteObject(cir) if i < num_apartment_floors - 1: add_apartment_columns(level_z) add_balconies(level_z) # Create a spiral ramp for the parking levels spiral = rs.AddSpiral([0, 0, 0], [0, 0, 1], floor_height, num_parking_floors - 1, ramp_radius) spiral_flat, tothgt = fc.curve_to_stairline(spiral) fc.make_curved_ramp(spiral_flat, tothgt) rs.DeleteObject(spiral)