aidl/side view of cabinet with drawers in opposite directions/side view of cabinet with drawers in opposite directions6


CLIP Score: 30.13

Image

Program

Conversation

side view of cabinet with drawers in opposite directions6 image
                
from AIDL import *

def cabinet(
        cabinet_width: float = 24 * inches,
        cabinet_height: float = 36 * inches,
        cabinet_depth: float = 18 * inches,
        drawer_width: float = 22 * inches,
        drawer_height: float = 6 * inches,
        drawer_depth: float = 16 * inches,
        handle_radius: float = 1 * inch,
):
    cabinet = Solid()
    drawer1 = Solid(shift=(0, -cabinet_height / 4))
    drawer2 = Solid(shift=(0, cabinet_height / 4))

    cabinet.drawer1 = drawer1
    cabinet.drawer2 = drawer2

    # Main cabinet body
    cabinet.body = Rectangle((0, 0), cabinet_width, cabinet_height)

    # Drawers
    drawer1.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)
    drawer2.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)
    
    # Drawer handles
    drawer1.handle = Hole(shift=(cabinet_width / 2 + 0.9*drawer_width / 2, 0))
    drawer2.handle = Hole(shift=(cabinet_width / 2 - 0.9*drawer_width / 2, 0))

    drawer1.handle.circle = Circle((0, 0), handle_radius)
    drawer2.handle.circle = Circle((0, 0), handle_radius)

    # Constraints for cabinet and drawers positions
    cabinet.AddConstraint(drawer1.bb.left >= cabinet.bb.left)  # Drawer 1 within cabinet
    cabinet.AddConstraint(drawer1.bb.right <= cabinet.bb.right)  # Drawer 1 within cabinet
    cabinet.AddConstraint(drawer2.bb.left >= cabinet.bb.left)  # Drawer 2 within cabinet
    cabinet.AddConstraint(drawer2.bb.right <= cabinet.bb.right)  # Drawer 2 within cabinet
    cabinet.AddConstraint(drawer1.bb.horizontal_center == drawer2.bb.horizontal_center)
    cabinet.AddConstraint(drawer1.bb.vertical_center == -cabinet_height / 4)
    cabinet.AddConstraint(drawer2.bb.vertical_center == cabinet_height / 4)

    return cabinet

with AIDL_2D:
    model = cabinet()
print(model.Solve())
model.Render()

                
                Please write an AIDL program to generate a side view of cabinet with drawers in opposite directions

Got it! Let's start by laying out the basic structure of the cabinet and the drawers. We'll follow the step-by-step approach:

1. **Define the main structure**: A cabinet which will be the `Solid` root.
2. **Define the drawers**: Two `Solid` drawers extending in opposite directions.
3. **Define the drawer handles**: Holes to represent cutouts for handles on the drawers.
4. **Set constraints**: To ensure the drawers are properly positioned and oriented.

Let's move forward with the basic implementation and then add details progressively.

### Step 1: Define the main structure and drawers

We'll first define the cabinet and its two drawers.

```python
from AIDL import *

def cabinet(
        cabinet_width: float = 24 * inches,
        cabinet_height: float = 36 * inches,
        cabinet_depth: float = 18 * inches,  # depth not shown in side view but needed conceptually
        drawer_width: float = 22 * inches,
        drawer_height: float = 6 * inches,
        drawer_depth: float = 16 * inches,
):
    cabinet = Solid()
    drawer1 = Solid(shift=(0, -cabinet_height / 4))
    drawer2 = Solid(shift=(0, cabinet_height / 4))

    cabinet.drawer1 = drawer1
    cabinet.drawer2 = drawer2

    return cabinet

with AIDL_2D:
    model = cabinet()
print(model.Solve())
model.Render()
```

### Step 2: Add geometry for the drawers

Next, we add rectangles to represent the drawers and a cabinet body.

```python
from AIDL import *

def cabinet(
        cabinet_width: float = 24 * inches,
        cabinet_height: float = 36 * inches,
        cabinet_depth: float = 18 * inches,
        drawer_width: float = 22 * inches,
        drawer_height: float = 6 * inches,
        drawer_depth: float = 16 * inches,
):
    cabinet = Solid()
    drawer1 = Solid(shift=(0, -cabinet_height / 4))
    drawer2 = Solid(shift=(0, cabinet_height / 4))

    cabinet.drawer1 = drawer1
    cabinet.drawer2 = drawer2

    cabinet.body = Rectangle((0, 0), cabinet_width, cabinet_height)
    drawer1.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)
    drawer2.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)

    return cabinet

with AIDL_2D:
    model = cabinet()
print(model.Solve())
model.Render()
```

### Step 3: Add holes for drawer handles

Let's add holes to represent where the drawer handles would be.

```python
from AIDL import *

def cabinet(
        cabinet_width: float = 24 * inches,
        cabinet_height: float = 36 * inches,
        cabinet_depth: float = 18 * inches,
        drawer_width: float = 22 * inches,
        drawer_height: float = 6 * inches,
        drawer_depth: float = 16 * inches,
        handle_radius: float = 1 * inch,
):
    cabinet = Solid()
    drawer1 = Solid(shift=(0, -cabinet_height / 4))
    drawer2 = Solid(shift=(0, cabinet_height / 4))

    cabinet.drawer1 = drawer1
    cabinet.drawer2 = drawer2

    cabinet.body = Rectangle((0, 0), cabinet_width, cabinet_height)
    drawer1.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)
    drawer2.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)

    drawer1.handle = Hole(shift=(cabinet_width / 2 + 0.9*drawer_width / 2, 0))
    drawer2.handle = Hole(shift=(cabinet_width / 2 - 0.9*drawer_width / 2, 0))

    drawer1.handle.circle = Circle((0, 0), handle_radius)
    drawer2.handle.circle = Circle((0, 0), handle_radius)

    return cabinet

with AIDL_2D:
    model = cabinet()
print(model.Solve())
model.Render()
```

### Step 4: Define constraints

Now, we'll ensure the drawers fit within the cabinet and are appropriately horizontally and vertically aligned.

```python
from AIDL import *

def cabinet(
        cabinet_width: float = 24 * inches,
        cabinet_height: float = 36 * inches,
        cabinet_depth: float = 18 * inches,
        drawer_width: float = 22 * inches,
        drawer_height: float = 6 * inches,
        drawer_depth: float = 16 * inches,
        handle_radius: float = 1 * inch,
):
    cabinet = Solid()
    drawer1 = Solid(shift=(0, -cabinet_height / 4))
    drawer2 = Solid(shift=(0, cabinet_height / 4))

    cabinet.drawer1 = drawer1
    cabinet.drawer2 = drawer2

    # Main cabinet body
    cabinet.body = Rectangle((0, 0), cabinet_width, cabinet_height)

    # Drawers
    drawer1.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)
    drawer2.body = Rectangle((cabinet_width / 2, 0), drawer_width, drawer_height)
    
    # Drawer handles
    drawer1.handle = Hole(shift=(cabinet_width / 2 + 0.9*drawer_width / 2, 0))
    drawer2.handle = Hole(shift=(cabinet_width / 2 - 0.9*drawer_width / 2, 0))

    drawer1.handle.circle = Circle((0, 0), handle_radius)
    drawer2.handle.circle = Circle((0, 0), handle_radius)

    # Constraints for cabinet and drawers positions
    cabinet.AddConstraint(drawer1.bb.left >= cabinet.bb.left)  # Drawer 1 within cabinet
    cabinet.AddConstraint(drawer1.bb.right <= cabinet.bb.right)  # Drawer 1 within cabinet
    cabinet.AddConstraint(drawer2.bb.left >= cabinet.bb.left)  # Drawer 2 within cabinet
    cabinet.AddConstraint(drawer2.bb.right <= cabinet.bb.right)  # Drawer 2 within cabinet
    cabinet.AddConstraint(drawer1.bb.horizontal_center == drawer2.bb.horizontal_center)
    cabinet.AddConstraint(drawer1.bb.vertical_center == -cabinet_height / 4)
    cabinet.AddConstraint(drawer2.bb.vertical_center == cabinet_height / 4)

    return cabinet

with AIDL_2D:
    model = cabinet()
print(model.Solve())
model.Render()
```

This should give you a side view of a cabinet with drawers extending in opposite directions. Please let me know if you need any adjustments or additional details!