import rhinoscriptsyntax as rs def create_two_vertical_rectangles_and_boxes_with_normal_above(): # Clear all objects in the scene allobjs = rs.AllObjects() if allobjs: rs.DeleteObjects(allobjs) # Define the dimensions for the vertical rectangles length = 4 # X-axis (width of the rectangle) width = 4 # Y-axis (thickness of the rectangle) height = 10 # Z-axis (height of the rectangle) # Create the first vertical rectangle and extrude it to make it a solid box base1 = rs.AddRectangle((-4, 0, 0), length, width) # Base on the X-Y plane rectangle1 = rs.ExtrudeCurveStraight(base1, (0, 0, 0), (0, 0, height)) # Extrude it in the Z direction rectangle1 = rs.CapPlanarHoles(rectangle1) # Make it a closed solid box # Create the second vertical rectangle and extrude it to make it a solid box base2 = rs.AddRectangle((length + 4, 0, 0), length, width) # Offset the second rectangle along X-axis rectangle2 = rs.ExtrudeCurveStraight(base2, (0, 0, 0), (0, 0, height)) # Extrude it in the Z direction rectangle2 = rs.CapPlanarHoles(rectangle2) # Make it a closed solid box # Now create the horizontal rectangle above the two vertical rectangles and extrude it to make it a solid box horizontal_length = 22.5 # Shorter length for the horizontal rectangle horizontal_width = 4 # Width of the horizontal rectangle horizontal_offset = 2 # Small offset to center the horizontal rectangle # The horizontal rectangle will be placed just above the vertical rectangles base3 = rs.AddRectangle((length / 2 - horizontal_length / 2 + horizontal_offset, 0, height), horizontal_length, horizontal_width) # Extrude the horizontal rectangle to give it volume and make it a solid box horizontal_rectangle = rs.ExtrudeCurveStraight(base3, (0, 0, height), (0, 0, height + 4)) # Short extrusion horizontal_rectangle = rs.CapPlanarHoles(horizontal_rectangle) # Make it a closed solid box # Now create two more boxes above the horizontal box, directly above the two vertical rectangles new_box_height = 0.8 # Height of the new boxes above the horizontal rectangle # Create the first new box above the first vertical rectangle base4 = rs.AddRectangle((-4, 0, height + 4), length, width) # Positioned directly above the first vertical rectangle new_box1 = rs.ExtrudeCurveStraight(base4, (0, 0, 0), (0, 0, new_box_height)) # Extrude it to make it a solid box new_box1 = rs.CapPlanarHoles(new_box1) # Close the new box # Create the second new box above the second vertical rectangle base5 = rs.AddRectangle((length + 4, 0, height + 4), length, width) # Positioned above the second vertical rectangle new_box2 = rs.ExtrudeCurveStraight(base5, (0, 0, 0), (0, 0, new_box_height)) # Extrude it to make it a solid box new_box2 = rs.CapPlanarHoles(new_box2) # Close the new box # Now add two normal boxes directly above the two new boxes new_above_box_height = 4 # Height of the new boxes above the new boxes # Create the first new normal box above the first new box base6 = rs.AddRectangle((length - 4, -8, height + 4 + new_box_height), -4, 20) # Positioned above new_box1 normal_box1 = rs.ExtrudeCurveStraight(base6, (0, 0, 0), (0, 0, new_above_box_height)) # Extrude it to make it a solid box normal_box1 = rs.CapPlanarHoles(normal_box1) # Close the normal box above new_box1 # Create the second new normal box above the second new box base7 = rs.AddRectangle((length + 4, -8, height + 4 + new_box_height), 4, 20) # Positioned above new_box2 normal_box2 = rs.ExtrudeCurveStraight(base7, (0, 0, 0), (0, 0, new_above_box_height)) # Extrude it to make it a solid box normal_box2 = rs.CapPlanarHoles(normal_box2) # Close the normal box above new_box2 # Now repeat the same new boxes and normal boxes above the new horizontal box # Create two new boxes above the new horizontal box base8 = rs.AddRectangle((-4, 0, height + 6 + new_box_height + new_above_box_height + 2), length, width) # Positioned above the new horizontal box new_box3 = rs.ExtrudeCurveStraight(base8, (0, 0, 0), (0, 0, new_box_height)) # Extrude it to make it a solid box new_box3 = rs.CapPlanarHoles(new_box3) # Close the new box base9 = rs.AddRectangle((length + 4, 0, height + 6 + new_box_height + new_above_box_height + 2), length, width) # Positioned above the new horizontal box new_box4 = rs.ExtrudeCurveStraight(base9, (0, 0, 0), (0, 0, new_box_height)) # Extrude it to make it a solid box new_box4 = rs.CapPlanarHoles(new_box4) # Close the new box # Now add two normal boxes directly above the two new boxes base10 = rs.AddRectangle((length - 4, -8, height + 6 + new_box_height + new_above_box_height + 2 + new_box_height), -4, 20) # Positioned above new_box3 normal_box3 = rs.ExtrudeCurveStraight(base10, (0, 0, 0), (0, 0, new_above_box_height)) # Extrude it to make it a solid box normal_box3 = rs.CapPlanarHoles(normal_box3) # Close the normal box above new_box3 base11 = rs.AddRectangle((length + 4, -8, height + 6 + new_box_height + new_above_box_height + 2 + new_box_height), 4, 20) # Positioned above new_box4 normal_box4 = rs.ExtrudeCurveStraight(base11, (0, 0, 0), (0, 0, new_above_box_height)) # Extrude it to make it a solid box normal_box4 = rs.CapPlanarHoles(normal_box4) # Close the normal box above new_box4 #--[Windows Horizontal (5)]---------------------------------------------------------------------------------------------------------------------------- window_width = 3 # Width of each window window_height = 1 # Height of each window window_depth = 0.5 # Depth of each window window_spacing = 1 # Spacing between windows # Create windows along the horizontal rectangle windows = [] for i in range(5): # Create windows window_x = (length / 1 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, -window_depth / 2, height + 2), window_width, window_depth + 4) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) for i in range(5): # Create windows window_x = (length / 1 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, -window_depth / 2, height + 0.5), window_width, window_depth + 4) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) # Add the same horizontal box on top of the new boxes horizontal_box_top = rs.AddRectangle((length / 2 - horizontal_length / 2 + horizontal_offset, 0, height + 4 + new_box_height + new_above_box_height), horizontal_length, horizontal_width) horizontal_box_top = rs.ExtrudeCurveStraight(horizontal_box_top, (0, 0, 0), (0, 0, 4)) # Extrude it to make it a solid box horizontal_box_top = rs.CapPlanarHoles(horizontal_box_top) # Close the horizontal box for i in range(5): # Create windows window_x = (length / 1 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, -window_depth / 2, height + 11), window_width, window_depth + 4) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) for i in range(5): # Create windows window_x = (length / 1 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, -window_depth / 2, height + 9.5), window_width, window_depth + 4) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) #--[Windows Horizontal (2)]---------------------------------------------------------------------------------------------------------------------------- window_width = 1 # Width of each window window_height = 1 # Height of each window window_depth = 0.5 # Depth of each window window_spacing = 11.2 # Spacing between windows windows = [] for i in range(2): # Create windows window_x = (length / 0.6 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, window_depth - 8.8, height + 16), window_width, window_depth + 20.1) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) for i in range(2): # Create windows window_x = (length / 0.6 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, window_depth - 8.8, height + 14), window_width, window_depth + 20.1) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) windows = [] for i in range(2): # Create windows window_x = (length / 0.6 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, window_depth - 8.8, height + 7.2), window_width, window_depth + 20.1) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) for i in range(2): # Create windows window_x = (length / 0.6 - horizontal_length / 2 + horizontal_offset) + (window_spacing + window_width) * i window_base = rs.AddRectangle((window_x, window_depth - 8.8, height + 5.2), window_width, window_depth + 20.1) window = rs.ExtrudeCurveStraight(window_base, (0, 0, 0), (0, 0, window_height)) window = rs.CapPlanarHoles(window) windows.append(window) #--[Add Top Box]---------------------------------------------------------------------------------------------------------------------------- # **Fixing the new boxes directly on top of the existing structure** new_top_box_height = 2 # Height for the new boxes at the top # These boxes will be aligned to sit directly on top of the existing box highest_z = height + 8 + 2 * new_box_height + 2 * new_above_box_height # The height where the new boxes should sit #--[First Top Box]---------------------------------------------------------------------------------------------------------------------------- # Create the first new box on top base12 = rs.AddRectangle((-4, 0, highest_z), length, width) # Positioned above everything new_top_box1 = rs.ExtrudeCurveStraight(base12, (0, 0, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box1 = rs.CapPlanarHoles(new_top_box1) # Close the new box at the top # Create the trinagle base12 = rs.AddRectangle((0, 2, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box1 = rs.ExtrudeCurveStraight(base12, (0, 2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box1 = rs.CapPlanarHoles(new_top_box1) # Close the new box at the top # Create the trinagle base12 = rs.AddRectangle((-3, 2, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box1 = rs.ExtrudeCurveStraight(base12, (0, 2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box1 = rs.CapPlanarHoles(new_top_box1) # Close the new box at the top # Create the trinagle base12 = rs.AddRectangle((0, -2.5, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box1 = rs.ExtrudeCurveStraight(base12, (0, -2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box1 = rs.CapPlanarHoles(new_top_box1) # Close the new box at the top # Create the trinagle base12 = rs.AddRectangle((-3, -2.5, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box1 = rs.ExtrudeCurveStraight(base12, (0, -2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box1 = rs.CapPlanarHoles(new_top_box1) # Close the new box at the top #--[Second Top Box]---------------------------------------------------------------------------------------------------------------------------- # Create the second new box on top base13 = rs.AddRectangle((length + 4, 0, highest_z), length, width) # Positioned above everything new_top_box2 = rs.ExtrudeCurveStraight(base13, (0, 0, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box2 = rs.CapPlanarHoles(new_top_box2) # Close the new box at the top # Create the trinagle base13 = rs.AddRectangle((length + 5, 2, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box2 = rs.ExtrudeCurveStraight(base13, (0, 2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box2 = rs.CapPlanarHoles(new_top_box2) # Close the new box at the top # Create the trinagle base13 = rs.AddRectangle((length + 8, 2, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box2 = rs.ExtrudeCurveStraight(base13, (0, 2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box2 = rs.CapPlanarHoles(new_top_box2) # Close the new box at the top # Create the trinagle base13 = rs.AddRectangle((length + 5, -2.5, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box2 = rs.ExtrudeCurveStraight(base13, (0, -2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box2 = rs.CapPlanarHoles(new_top_box2) # Close the new box at the top # Create the trinagle base13 = rs.AddRectangle((length + 8, -2.5, highest_z), length - 5, width + 0.5) # Positioned above everything new_top_box2 = rs.ExtrudeCurveStraight(base13, (0, -2, 0), (0, 0, new_top_box_height)) # Extrude it to make it a solid box new_top_box2 = rs.CapPlanarHoles(new_top_box2) # Close the new box at the top # Run the function create_two_vertical_rectangles_and_boxes_with_normal_above()