 |
CLIP Score: 29.07
from AIDL import *
def cabinet_with_drawers(
width: float = 24 * inches,
height: float = 30 * inches,
depth: float = 18 * inches,
drawer_height: float = 6 * inches
):
# Root structure for the cabinet
cabinet = Solid()
# Main frame of the cabinet
frame = Solid()
cabinet.frame = frame
# Frame geometry - simple rectangle representing the side view of the cabinet
frame.body = Rectangle((-width / 2, -height / 2), width, height)
# Drawers facing in opposite directions
drawer1 = Solid(shift=(depth / 2, 0)) # Drawer 1 shifted by half the depth to the right
drawer2 = Solid(shift=(-depth / 2, 0)) # Drawer 2 shifted by half the depth to the left
cabinet.drawer1 = drawer1
cabinet.drawer2 = drawer2
# Drawer geometry - simple rectangles for the side views of the drawers
drawer1.body = Rectangle((-depth / 2, -drawer_height / 2), depth, drawer_height)
drawer2.body = Rectangle((-depth / 2, -drawer_height / 2), depth, drawer_height)
# Add constraints to position drawers relative to the frame
cabinet.AddConstraint(drawer1.bb.vertical_center == frame.bb.vertical_center)
cabinet.AddConstraint(drawer2.bb.vertical_center == frame.bb.vertical_center)
cabinet.AddConstraint(drawer1.bb.horizontal_center == frame.bb.horizontal_center + depth / 2)
cabinet.AddConstraint(drawer2.bb.horizontal_center == frame.bb.horizontal_center - depth / 2)
# Return the root structure
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
Sure, let's break it down step by step to generate an AIDL program for the side view of a cabinet with drawers facing opposite directions.
### Step 1: Define the Structures and their Hierarchical Relationships
We'll start by creating a container `cabinet` structure. We'll then add children structures such as `frame`, `drawer1`, and `drawer2`. The `frame` will represent the main body of the cabinet, and `drawer1` and `drawer2` will represent the drawers facing in opposite directions.
### Step 2: Add Constraints to the Structures
We'll add constraints to position the drawers relative to the frame. This includes making sure that the drawers are opposite to each other and centered within the frame.
### Step 3: Create Geometry for Each Structure
We'll start with defining the frame's geometry and then define the geometries for the drawers.
Let's start with step 1 and define the structures and their hierarchical relationships.
### Step 1: Define the Structures and their Hierarchical Relationships
```python
from AIDL import *
def cabinet_with_drawers(
width: float = 24 * inches,
height: float = 30 * inches,
depth: float = 18 * inches,
drawer_height: float = 6 * inches
):
# Root structure for the cabinet
cabinet = Solid()
# Main frame of the cabinet
frame = Solid()
cabinet.frame = frame
# Drawers facing in opposite directions
drawer1 = Solid(shift=(depth / 2, 0)) # Drawer 1 shifted by half the depth to the right
drawer2 = Solid(shift=(-depth / 2, 0)) # Drawer 2 shifted by half the depth to the left
cabinet.drawer1 = drawer1
cabinet.drawer2 = drawer2
# Return the root structure
return cabinet
with AIDL_2D:
model = cabinet_with_drawers()
print(model.Solve())
model.Render()
```
Next, let's move on to step 2 and define the constraints to position the drawers relative to the frame.
### Step 2: Add Constraints to the Structures
We'll add constraints to ensure the drawers are centered within the frame and face opposite directions.
```python
from AIDL import *
def cabinet_with_drawers(
width: float = 24 * inches,
height: float = 30 * inches,
depth: float = 18 * inches,
drawer_height: float = 6 * inches
):
# Root structure for the cabinet
cabinet = Solid()
# Main frame of the cabinet
frame = Solid()
cabinet.frame = frame
# Drawers facing in opposite directions
drawer1 = Solid(shift=(depth / 2, 0)) # Drawer 1 shifted by half the depth to the right
drawer2 = Solid(shift=(-depth / 2, 0)) # Drawer 2 shifted by half the depth to the left
cabinet.drawer1 = drawer1
cabinet.drawer2 = drawer2
# Add constraints to position drawers relative to the frame
cabinet.AddConstraint(drawer1.bb.vertical_center == frame.bb.vertical_center)
cabinet.AddConstraint(drawer2.bb.vertical_center == frame.bb.vertical_center)
cabinet.AddConstraint(drawer1.bb.horizontal_center == frame.bb.horizontal_center + depth / 2)
cabinet.AddConstraint(drawer2.bb.horizontal_center == frame.bb.horizontal_center - depth / 2)
# Return the root structure
return cabinet
with AIDL_2D:
model = cabinet_with_drawers()
print(model.Solve())
model.Render()
```
Lastly, let's move on to step 3 and add the geometry for each structure.
### Step 3: Create Geometry for Each Structure
We'll start by defining the frame's geometry and then define the geometries for the drawers.
```python
from AIDL import *
def cabinet_with_drawers(
width: float = 24 * inches,
height: float = 30 * inches,
depth: float = 18 * inches,
drawer_height: float = 6 * inches
):
# Root structure for the cabinet
cabinet = Solid()
# Main frame of the cabinet
frame = Solid()
cabinet.frame = frame
# Frame geometry - simple rectangle representing the side view of the cabinet
frame.body = Rectangle((-width / 2, -height / 2), width, height)
# Drawers facing in opposite directions
drawer1 = Solid(shift=(depth / 2, 0)) # Drawer 1 shifted by half the depth to the right
drawer2 = Solid(shift=(-depth / 2, 0)) # Drawer 2 shifted by half the depth to the left
cabinet.drawer1 = drawer1
cabinet.drawer2 = drawer2
# Drawer geometry - simple rectangles for the side views of the drawers
drawer1.body = Rectangle((-depth / 2, -drawer_height / 2), depth, drawer_height)
drawer2.body = Rectangle((-depth / 2, -drawer_height / 2), depth, drawer_height)
# Add constraints to position drawers relative to the frame
cabinet.AddConstraint(drawer1.bb.vertical_center == frame.bb.vertical_center)
cabinet.AddConstraint(drawer2.bb.vertical_center == frame.bb.vertical_center)
cabinet.AddConstraint(drawer1.bb.horizontal_center == frame.bb.horizontal_center + depth / 2)
cabinet.AddConstraint(drawer2.bb.horizontal_center == frame.bb.horizontal_center - depth / 2)
# Return the root structure
return cabinet
with AIDL_2D:
model = cabinet_with_drawers()
print(model.Solve())
model.Render()
```
This should give us a basic side view of a cabinet with drawers facing opposite directions. Let me know if there's any additional detail you'd like to add or modify!
|