import rhinoscriptsyntax as rs import math # Clean the workspace rs.DeleteObjects(rs.AllObjects()) rs.EnableRedraw(False) def create_floors_with_tilt_and_facades( num_floors=10, base_radius=15, thickness=0.2, pipe_radius=0.2, floor_offset=3 ): """ Creates a tilted structure with multiple floors, ceilings, pipes, and a facade. Parameters: num_floors (int): Number of floors to create. base_radius (float): Radius of the floor discs. thickness (float): Thickness of the discs (floor and ceiling). pipe_radius (float): Radius of the vertical pipes. floor_offset (float): Height offset between consecutive floors. """ # Initial tilt and tilt decrement per floor initial_tilt = 3 final_tilt = 1.4 tilt_decrement = (initial_tilt - final_tilt) / (num_floors - 1) # Number of pipes and angle increment num_pipes = 12 angle_increment = 360 / num_pipes pipe_endpoints_all=[] for i in range(num_floors): # Calculate tilt for the current floor current_tilt = initial_tilt - i * tilt_decrement # Calculate Z offset and tilt offsets for this floor z_offset = i * floor_offset tilt_x_offset = i * current_tilt tilt_y_offset = i * current_tilt # Define floor and ceiling positions base_center_floor = (tilt_x_offset, tilt_y_offset, z_offset) base_center_ceiling = ( tilt_x_offset, tilt_y_offset, z_offset + thickness ) # Create floor and ceiling if i >num_floors-4: base_radius=base_radius-3 floor_disc = rs.AddCylinder(base_center_floor, thickness, base_radius) ceiling_disc = rs.AddCylinder(base_center_ceiling, thickness, base_radius) pipe_endpoints=[] # Create pipes for this floor for j in range(num_pipes): angle = j * angle_increment x = base_radius * math.cos(math.radians(angle)) y = base_radius * math.sin(math.radians(angle)) pipe_start = (x + tilt_x_offset, y + tilt_y_offset, z_offset + thickness) pipe_end = ( x + tilt_x_offset, y + tilt_y_offset, z_offset + floor_offset, ) pipe_endpoints.append(pipe_end) # Add pipe only if it's below the last ceiling if i < num_floors - 1: rs.AddPipe(rs.AddLine(pipe_start, pipe_end), 0, pipe_radius) pipe_endpoints_all.append(pipe_endpoints) print pipe_endpoints_all # Create facade for this floor if i < num_floors - 1: facade_base_points = [] for j in range(num_pipes): angle = j * angle_increment x = base_radius * math.cos(math.radians(angle)) y = base_radius * math.sin(math.radians(angle)) # Base and top points for the facade base_point = (x + tilt_x_offset, y + tilt_y_offset, z_offset) top_point = ( x + tilt_x_offset, y + tilt_y_offset, z_offset + floor_offset, ) facade_base_points.append(base_point) # Close the loop and create the facade facade_base_points.append(facade_base_points[0]) facade_curve = rs.AddPolyline(facade_base_points) rs.ExtrudeCurveStraight( facade_curve, (0, 0, 0), (0, 0, floor_offset) ) print("Structure created with floors, ceilings, pipes, and facades.") C1= rs.AddCurve((pipe_endpoints_all[0][4],[pipe_endpoints_all[3][4][0]-5,pipe_endpoints_all[6][4][1]-5,pipe_endpoints_all[6][4][2]+2], pipe_endpoints_all[8][4])) C2= rs.AddCurve((pipe_endpoints_all[0][5],[pipe_endpoints_all[3][5][0]-5,pipe_endpoints_all[3][5][1]-5,pipe_endpoints_all[3][5][2]+8], pipe_endpoints_all[8][5])) C3= rs.AddCurve((pipe_endpoints_all[0][6],[pipe_endpoints_all[3][6][0]-4,pipe_endpoints_all[3][6][1]-5,pipe_endpoints_all[3][6][2]+8], pipe_endpoints_all[8][6])) C4= rs.AddCurve((pipe_endpoints_all[0][7],[pipe_endpoints_all[3][7][0]-3,pipe_endpoints_all[3][7][1]-5,pipe_endpoints_all[3][7][2]+8], pipe_endpoints_all[8][7])) C5= rs.AddCurve((pipe_endpoints_all[0][8],[pipe_endpoints_all[3][8][0]-2,pipe_endpoints_all[3][8][1]-5,pipe_endpoints_all[3][8][2]+8], pipe_endpoints_all[8][8])) C6= rs.AddCurve((pipe_endpoints_all[0][9],[pipe_endpoints_all[3][9][0]-3,pipe_endpoints_all[3][9][1]-5,pipe_endpoints_all[3][9][2]+8], pipe_endpoints_all[8][9])) C7= rs.AddCurve((pipe_endpoints_all[0][10],[pipe_endpoints_all[3][10][0]-4,pipe_endpoints_all[3][10][1]-5,pipe_endpoints_all[3][10][2]+8], pipe_endpoints_all[8][10])) C8= rs.AddCurve((pipe_endpoints_all[0][11],[pipe_endpoints_all[3][11][0]+5,pipe_endpoints_all[6][11][1]-5,pipe_endpoints_all[6][11][2]+2], pipe_endpoints_all[8][11])) C9= rs.AddCurve((pipe_endpoints_all[6][-2], pipe_endpoints_all[8][-2])) C10= rs.AddCurve((pipe_endpoints_all[6][-1], pipe_endpoints_all[8][-1])) C11= rs.AddCurve((pipe_endpoints_all[6][0], pipe_endpoints_all[8][0])) C12= rs.AddCurve((pipe_endpoints_all[6][1], pipe_endpoints_all[8][1])) C13= rs.AddCurve((pipe_endpoints_all[6][2], pipe_endpoints_all[8][2])) C14= rs.AddCurve((pipe_endpoints_all[6][3], pipe_endpoints_all[8][3])) C15= rs.AddCurve((pipe_endpoints_all[6][4], pipe_endpoints_all[8][4])) C16= rs.AddCurve((pipe_endpoints_all[6][5], pipe_endpoints_all[8][5])) rs.AddLoftSrf([C1,C2,C3,C4,C5,C6,C7,C8]) rs.AddLoftSrf([C9,C10,C11,C12,C13,C14,C15,C16]) # Call the function create_floors_with_tilt_and_facades()