import rhinoscriptsyntax as rs import math # Delete all objects before starting rs.DeleteObjects(rs.AllObjects()) def create_marina_tower(center, radius, floor_height, num_parking_floors, num_apartment_floors, parking_slots): #Variables: # center: Tuple of (x, y, z) for the center of the tower. # radius: Radius of the circular tower. # floor_height: Height of each floor. # num_parking_floors: Number of parking levels. # num_apartment_floors: Number of apartment levels. # parking_slots: Number of slots per floor (determines spacing). #Returns: #List of solid objects (floors, ramp, balconies, and columns). building_solids = [] # Create the spiral ramp for parking floors ramp_path = [] # path of the spiral ramp ramp_width = radius / 5 # width of the ramp # Generate the points for the spiral ramp for floor in range(num_parking_floors): for step in range(parking_slots): angle = 360 / parking_slots * step + floor * 360 angle_rad = math.radians(angle) x = center[0] + (radius - ramp_width / 2) * math.cos(angle_rad) y = center[1] + (radius - ramp_width / 2) * math.sin(angle_rad) z = center[2] + floor * floor_height + (step / parking_slots) * floor_height ramp_path.append((x, y, z)) # Create the ramp from the calculated path ramp_curve = rs.AddInterpCurve(ramp_path) # curve for the ramp path ramp_section = rs.AddRectangle(rs.PlaneFromNormal(ramp_path[0], [math.cos(math.radians(0)), math.sin(math.radians(0)), 0]), ramp_width, floor_height / 10) # Ramp cross-section ramp_surface = rs.ExtrudeCurve(ramp_section, ramp_curve) # extrude along the curve ramp_solid = rs.CapPlanarHoles(ramp_surface) # close the ramp to make it solid rs.DeleteObject(ramp_section) # clean up temps building_solids.append(ramp_solid) # Create parking and apartment floors for floor in range(num_parking_floors + num_apartment_floors): z = center[2] + floor * floor_height # Elevation of the current floor floor_center = (center[0], center[1], z) # Add the floor slab floor_slab = rs.AddCylinder(floor_center, floor_height / 2, radius) building_solids.append(floor_slab) # Add balconies for apartment floors if floor >= num_parking_floors: # balconies only for apartment floors num_balconies = 12 # balconies per floor balcony_radius = radius # radius of the balconies for b in range(num_balconies): angle = 360 / num_balconies * b # angle for each balcony angle_rad = math.radians(angle) x = center[0] + balcony_radius * math.cos(angle_rad) y = center[1] + balcony_radius * math.sin(angle_rad) # Adjust the height of the balcony to align with the floor slab balcony_center = (x, y, z + floor_height / 2 - floor_height / 10) # Add balcony as a cylinder balcony = rs.AddCylinder(balcony_center, floor_height / 10, radius / 10) building_solids.append(balcony) # columns for structural support num_columns = 12 # number of columns evenly spaced column_radius = 0.5 # radius of each column for floor in range(num_parking_floors + num_apartment_floors): z = center[2] + floor * floor_height # elevation of the current column segment for c in range(num_columns): angle = 360 / num_columns * c # angle for each column angle_rad = math.radians(angle) x = center[0] + (radius - 2) * math.cos(angle_rad) # column x-position y = center[1] + (radius - 2) * math.sin(angle_rad) # column y-position column_start = (x, y, z - floor_height / 2) # bottom of the column segment column_end = (x, y, z + floor_height / 2) # top of the column segment column = rs.AddCylinder(column_start, floor_height, column_radius) building_solids.append(column) return building_solids def main(): # Parameters for the Marina Tower model center = (0, 0, 0) # center of the tower radius = 20 # radius of the tower floor_height = 3 # height of each floor num_parking_floors = 20 # parking levels num_apartment_floors = 30 # apartment floors parking_slots = 36 # ramp segments per floor # Create the Marina Tower building = create_marina_tower(center, radius, floor_height, num_parking_floors, num_apartment_floors, parking_slots) print("Created a Marina Tower model. YAAAAS.") if __name__ == "__main__": main()