 |
CLIP Score: 28.95
from AIDL import *
def cabinet_with_drawers(
height: float = 3*feet,
width: float = 2*feet,
depth: float = 1.5*feet,
drawer_height: float = 1*feet,
drawer_width: float = 2*feet,
drawer_depth: float = 1*feet
):
"""
Model a simple cabinet with two drawers opening in opposite directions.
"""
cabinet = Solid()
# Define the main body of the cabinet
cabinet.body = Rectangle((0,0), width, height)
# Define the drawers; dimensions are smaller to fit within the cabinet and allow opening space
left_drawer = Rectangle((-width/4, -height/3), drawer_width/2, drawer_height)
right_drawer = Rectangle((width/4, height/3), drawer_width/2, drawer_height)
cabinet.left_drawer = Solid()
cabinet.left_drawer.left_rect = left_drawer
cabinet.right_drawer = Solid()
cabinet.right_drawer.right_rect = right_drawer
# Define the geometry for the handle slots to indicate directionality
left_handle_slot = Line((-width/4 - drawer_width/5, -height/3), (-width/4 - drawer_width/5, -height/3 + drawer_height/10))
right_handle_slot = Line((width/4 + drawer_width/4, height/3), (width/4 + drawer_width/4, height/3 - drawer_height/10))
cabinet.left_drawer.left_handle_slot = left_handle_slot
cabinet.right_drawer.right_handle_slot = right_handle_slot
return cabinet
with AIDL_2D:
model = cabinet_with_drawers()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a side view of cabinet with drawers in opposite directions
Got it. To generate a side view of a cabinet with drawers that open in opposite directions, let's define the cabinet's key components:
1. The main body of the cabinet.
2. Two drawers with the front faces in opposite directions (one to the left and one to the right).
We will utilize the following logic:
- The main body will be a simple rectangular Solid.
- Each drawer will be a smaller rectangle inside the main body.
- We will have two rectangles representing the drawers, positioned such that one is at the left side and the other at the right side of the cabinet body.
Here's the AIDL program to generate such a model:
```python
from AIDL import *
def cabinet_with_drawers(
height: float = 3*feet,
width: float = 2*feet,
depth: float = 1.5*feet,
drawer_height: float = 1*feet,
drawer_width: float = 2*feet,
drawer_depth: float = 1*feet
):
"""
Model a simple cabinet with two drawers opening in opposite directions.
"""
cabinet = Solid()
# Define the main body of the cabinet
cabinet.body = Rectangle((0,0), width, height)
# Define the drawers; dimensions are smaller to fit within the cabinet and allow opening space
left_drawer = Rectangle((-width/4, -height/3), drawer_width/2, drawer_height)
right_drawer = Rectangle((width/4, height/3), drawer_width/2, drawer_height)
cabinet.left_drawer = Solid()
cabinet.left_drawer.left_rect = left_drawer
cabinet.right_drawer = Solid()
cabinet.right_drawer.right_rect = right_drawer
# Define the geometry for the handle slots to indicate directionality
left_handle_slot = Line((-width/4 - drawer_width/5, -height/3), (-width/4 - drawer_width/5, -height/3 + drawer_height/10))
right_handle_slot = Line((width/4 + drawer_width/4, height/3), (width/4 + drawer_width/4, height/3 - drawer_height/10))
cabinet.left_drawer.left_handle_slot = left_handle_slot
cabinet.right_drawer.right_handle_slot = right_handle_slot
return cabinet
with AIDL_2D:
model = cabinet_with_drawers()
print(model.Solve())
model.Render()
```
### Explanation:
1. **Import Statement**: Import everything needed for AIDL and math.
2. **Function Definition**: Define the function `cabinet_with_drawers` with default parameters.
3. **Main Body**: Create the main body of the cabinet as a rectangle.
4. **Drawers**: Define two drawers as smaller rectangles offset in their positions.
5. **Handle Slots**: Add simple lines representing handles to visualize drawer orientation.
6. **Returning the Model**: Return the root `cabinet` structure.
This model allows you to visualize the two drawers within the cabinet body. Each drawer is modeled as a Solid structure and positioned to indicate that they open in opposite directions.
|