 |
CLIP Score: 28.43
from AIDL import *
def cabinet(
width: float = 30*inches,
height: float = 72*inches,
depth: float = 18*inches,
material_thickness: float = 0.75*inches,
num_shelves: int = 3
):
"""
Generate a simple cabinet with the given dimensions.
"""
# Define the main structure of the cabinet
cabinet = Assembly()
# Create the back panel
back_panel = Solid(shift=(0, 0))
cabinet.back_panel = back_panel
back_panel.shape = Rectangle((0, 0), width, height)
# Create the side panels
left_side = Solid(shift=(-width/2 + material_thickness/2, 0))
right_side = Solid(shift=(width/2 - material_thickness/2, 0))
cabinet.left_side = left_side
cabinet.right_side = right_side
left_side.shape = Rectangle((0, 0), depth, height)
right_side.shape = Rectangle((0, 0), depth, height)
# Create the top panel
top_panel = Solid(shift=(0, height/2 - material_thickness/2))
cabinet.top_panel = top_panel
top_panel.shape = Rectangle((0, 0), width, depth)
# Create the bottom panel
bottom_panel = Solid(shift=(0, -height/2 + material_thickness/2))
cabinet.bottom_panel = bottom_panel
bottom_panel.shape = Rectangle((0, 0), width, depth)
# Create shelves
shelf_spacing = (height - (2 * material_thickness)) / (num_shelves + 1)
cabinet.shelves = []
for i in range(num_shelves):
shelf_shift = (0, height/2 - (i + 1) * shelf_spacing - material_thickness)
shelf = Solid(shift=shelf_shift)
cabinet.shelves.append(shelf)
shelf.shape = Rectangle((0, 0), width, depth)
return cabinet
with AIDL_2D:
model = cabinet()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a cabinet
Sure! We'll create a simple cabinet model using AIDL. This cabinet will have a rectangular body with shelves. For simplicity, let's assume it has three shelves and a back panel. We will not create detailed doors or intricate patterns for now.
Let's start by defining the basic parameters for the cabinet:
- Width, height, and depth of the cabinet
- Number of shelves
- Thickness of the material
Let's break this task into small steps. We're going to build this model step-by-step, defining the structure nodes and their geometry as we progress.
1. Define the main structure of the cabinet.
2. Create structural elements like back panel, sides, top, bottom, and shelves.
Here is the step-by-step AIDL program for the cabinet:
```python
from AIDL import *
def cabinet(
width: float = 30*inches,
height: float = 72*inches,
depth: float = 18*inches,
material_thickness: float = 0.75*inches,
num_shelves: int = 3
):
"""
Generate a simple cabinet with the given dimensions.
"""
# Define the main structure of the cabinet
cabinet = Assembly()
# Create the back panel
back_panel = Solid(shift=(0, 0))
cabinet.back_panel = back_panel
back_panel.shape = Rectangle((0, 0), width, height)
# Create the side panels
left_side = Solid(shift=(-width/2 + material_thickness/2, 0))
right_side = Solid(shift=(width/2 - material_thickness/2, 0))
cabinet.left_side = left_side
cabinet.right_side = right_side
left_side.shape = Rectangle((0, 0), depth, height)
right_side.shape = Rectangle((0, 0), depth, height)
# Create the top panel
top_panel = Solid(shift=(0, height/2 - material_thickness/2))
cabinet.top_panel = top_panel
top_panel.shape = Rectangle((0, 0), width, depth)
# Create the bottom panel
bottom_panel = Solid(shift=(0, -height/2 + material_thickness/2))
cabinet.bottom_panel = bottom_panel
bottom_panel.shape = Rectangle((0, 0), width, depth)
# Create shelves
shelf_spacing = (height - (2 * material_thickness)) / (num_shelves + 1)
cabinet.shelves = []
for i in range(num_shelves):
shelf_shift = (0, height/2 - (i + 1) * shelf_spacing - material_thickness)
shelf = Solid(shift=shelf_shift)
cabinet.shelves.append(shelf)
shelf.shape = Rectangle((0, 0), width, depth)
return cabinet
with AIDL_2D:
model = cabinet()
print(model.Solve())
model.Render()
```
This script creates a simple cabinet with three shelves. Each component (back panel, side panels, top panel, bottom panel, shelves) is represented as a Solid structure, and all components are assembled together.
Please review the script and let me know if you have any questions or if additional details need to be added or modified.
|