 |
CLIP Score: 25.73
from AIDL import *
def cabinet_side_view(
cabinet_height: float = 36 * inches,
cabinet_width: float = 24 * inches,
cabinet_depth: float = 18 * inches,
drawer_height: float = 6 * inches,
drawer_gap: float = 1 * inches
):
"""
Model a side view of a cabinet with multiple drawers that open in opposite directions.
"""
# Define the cabinet structure
cabinet = Solid()
# Calculate the number of drawers
num_drawers = int(cabinet_height // (drawer_height + drawer_gap))
# Define the main body of the cabinet as a rectangle
cabinet.body = Rectangle((0, cabinet_height / 2), cabinet_depth, cabinet_height)
# Define the drawers as Solid structures inside the cabinet
drawers = []
for i in range(num_drawers):
drawer_shift = (i * (drawer_height + drawer_gap)) - (cabinet_height / 2 - drawer_height / 2)
if i % 2 == 0:
drawer = Solid(shift=(cabinet_depth / 2, drawer_shift))
drawer.shape = Rectangle((0, 0), cabinet_depth / 2, drawer_height)
else:
drawer = Solid(shift=(-cabinet_depth / 2, drawer_shift))
drawer.shape = Rectangle((0, 0), cabinet_depth / 2, drawer_height)
drawers.append(drawer)
# Add the drawers to the cabinet
cabinet.drawers = drawers
return cabinet
with AIDL_2D:
model = cabinet_side_view()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a side view of cabinet with drawers in opposite directions
Alright! Let's start by sketching out a basic plan for what we want in our cabinet with drawers. We will create a simple side view of a cabinet structure with multiple drawers that open in opposite directions.
### Plan
1. Define the overall cabinet structure.
2. Add a Solid structure for the main body of the cabinet.
3. Add drawers to the cabinet that open in opposite directions.
4. Use rectangular shapes to represent the drawers and the cabinet body.
We'll need some parameters:
- `cabinet_height`: The total height of the cabinet.
- `cabinet_width`: The total width of the cabinet.
- `cabinet_depth`: The depth of the cabinet (side view).
- `drawer_height`: The height of each drawer.
- `drawer_gap`: The gap between drawers.
Let’s put this into an AIDL program:
```python
from AIDL import *
def cabinet_side_view(
cabinet_height: float = 36 * inches,
cabinet_width: float = 24 * inches,
cabinet_depth: float = 18 * inches,
drawer_height: float = 6 * inches,
drawer_gap: float = 1 * inches
):
"""
Model a side view of a cabinet with multiple drawers that open in opposite directions.
"""
# Define the cabinet structure
cabinet = Solid()
# Calculate the number of drawers
num_drawers = int(cabinet_height // (drawer_height + drawer_gap))
# Define the main body of the cabinet as a rectangle
cabinet.body = Rectangle((0, cabinet_height / 2), cabinet_depth, cabinet_height)
# Define the drawers as Solid structures inside the cabinet
drawers = []
for i in range(num_drawers):
drawer_shift = (i * (drawer_height + drawer_gap)) - (cabinet_height / 2 - drawer_height / 2)
if i % 2 == 0:
drawer = Solid(shift=(cabinet_depth / 2, drawer_shift))
drawer.shape = Rectangle((0, 0), cabinet_depth / 2, drawer_height)
else:
drawer = Solid(shift=(-cabinet_depth / 2, drawer_shift))
drawer.shape = Rectangle((0, 0), cabinet_depth / 2, drawer_height)
drawers.append(drawer)
# Add the drawers to the cabinet
cabinet.drawers = drawers
return cabinet
with AIDL_2D:
model = cabinet_side_view()
print(model.Solve())
model.Render()
```
### Explanation
1. **Cabinet Structure**: We define the main cabinet as a Solid.
2. **Main Body**: We create the body of the cabinet using a `Rectangle` representing its overall dimensions.
3. **Drawers**: We loop through the number of drawers, and for each drawer, we create a `Solid` shifted up by an increment depending on its index. The drawers are placed alternatively to open in opposite directions.
This should provide a basic side view of a cabinet with drawers opening in opposite directions. Feel free to tweak the parameters and adjust the design to better fit your specific requirements! Let me know if you need further modifications or explanations.
|