noconstraints/cabinet/cabinet1


CLIP Score: 33.43

Image

Program

Conversation

cabinet1 image
                
from AIDL import *

def cabinet(
        width: float = 24 * inches,
        height: float = 36 * inches,
        depth: float = 12 * inches,
        door_thickness: float = 0.5 * inches
):
    """
    Model a simple rectangular cabinet with two doors and shelves inside.
    """

    # Main cabinet structure
    cabinet = Solid()
    frame = Solid()
    left_door = Solid(shift=(-width/4 - door_thickness/2, 0))
    right_door = Solid(shift=(width/4 + door_thickness/2, 0))
    shelves = Solid()

    # Attach substructures to the main cabinet
    cabinet.frame = frame
    cabinet.left_door = left_door
    cabinet.right_door = right_door
    cabinet.shelves = shelves

    # Frame geometry - rectangle representing the cabinet body
    frame.body = RoundedRectangle((0, 0), width, height, door_thickness / 4)

    # Back panel for support
    frame.back_panel = Rectangle((0, 0), width - 2*door_thickness, height - 2*door_thickness)

    # Doors geometry - rectangles representing the doors
    left_door.panel = Rectangle((0, 0), width/2, height)
    right_door.panel = Rectangle((0, 0), width/2, height)

    # Shelves geometry - rectangles representing the shelves
    n_shelves = 3
    shelf_spacing = height / (n_shelves + 1)
    shelves.shelf_list = [Rectangle((0, i * shelf_spacing - height / 2 + shelf_spacing), width, door_thickness) for i in range(1, n_shelves + 1)]

    return cabinet

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

                
                Please write an AIDL program to generate a cabinet

Sure! Let's get started on writing an AIDL program to generate a cabinet. I'll break it down step-by-step. For simplicity, we'll create a basic rectangular cabinet with two doors and shelves inside. Feel free to specify any additional details or modifications you'd like to include.

### Step 1: Define Imports and Function Signature
We'll start by importing everything from AIDL and defining the function signature for our cabinet model.

```python
from AIDL import *

def cabinet(
        width: float = 24 * inches,
        height: float = 36 * inches,
        depth: float = 12 * inches,
        door_thickness: float = 0.5 * inches
):
    """
    Model a simple rectangular cabinet with two doors and shelves inside.
    """
```

### Step 2: Define the Main Cabinet Structure
Next, we'll define the main structure of the cabinet as a `Solid`, along with substructures for doors, shelves, and the frame.

```python
    # Main cabinet structure
    cabinet = Solid()
    frame = Solid()
    left_door = Solid(shift=(-width/4 - door_thickness/2, 0))
    right_door = Solid(shift=(width/4 + door_thickness/2, 0))
    shelves = Solid()

    # Attach substructures to the main cabinet
    cabinet.frame = frame
    cabinet.left_door = left_door
    cabinet.right_door = right_door
    cabinet.shelves = shelves
```

### Step 3: Define the Frame Geometry
We'll create the rectangular frame of the cabinet, encompassing the sides, top, and bottom panels.

```python
    # Frame geometry - rectangle representing the cabinet body
    frame.body = RoundedRectangle((0, 0), width, height, door_thickness / 4)

    # Back panel for support
    frame.back_panel = Rectangle((0, 0), width - 2*door_thickness, height - 2*door_thickness)
```

### Step 4: Define the Doors Geometry
We'll create the geometry for the two doors of the cabinet.

```python
    # Doors geometry - rectangles representing the doors
    left_door.panel = Rectangle((0, 0), width/2, height)
    right_ddoor.panel = Rectangle((0, 0), width/2, height)
```

### Step 5: Define the Shelves Geometry
We'll add shelves to the cabinet. We'll create a few horizontal lines that represent the shelves.

```python
    # Shelves geometry - rectangles representing the shelves
    n_shelves = 3
    shelf_spacing = height / (n_shelves + 1)
    shelves.shelf_list = [Rectangle((0, i * shelf_spacing - height / 2 + shelf_spacing), width, door_thickness) for i in range(1, n_shelves + 1)]
```

### Step 6: Return the Cabinet Structure
Finish up by returning the cabinet structure from the function.

```python
    return cabinet
```

### Step 7: Solve and Render the Model
Finally, we create an instance of the cabinet model and render it.

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

### Complete Code
Here's the complete code:

```python
from AIDL import *

def cabinet(
        width: float = 24 * inches,
        height: float = 36 * inches,
        depth: float = 12 * inches,
        door_thickness: float = 0.5 * inches
):
    """
    Model a simple rectangular cabinet with two doors and shelves inside.
    """

    # Main cabinet structure
    cabinet = Solid()
    frame = Solid()
    left_door = Solid(shift=(-width/4 - door_thickness/2, 0))
    right_door = Solid(shift=(width/4 + door_thickness/2, 0))
    shelves = Solid()

    # Attach substructures to the main cabinet
    cabinet.frame = frame
    cabinet.left_door = left_door
    cabinet.right_door = right_door
    cabinet.shelves = shelves

    # Frame geometry - rectangle representing the cabinet body
    frame.body = RoundedRectangle((0, 0), width, height, door_thickness / 4)

    # Back panel for support
    frame.back_panel = Rectangle((0, 0), width - 2*door_thickness, height - 2*door_thickness)

    # Doors geometry - rectangles representing the doors
    left_door.panel = Rectangle((0, 0), width/2, height)
    right_door.panel = Rectangle((0, 0), width/2, height)

    # Shelves geometry - rectangles representing the shelves
    n_shelves = 3
    shelf_spacing = height / (n_shelves + 1)
    shelves.shelf_list = [Rectangle((0, i * shelf_spacing - height / 2 + shelf_spacing), width, door_thickness) for i in range(1, n_shelves + 1)]

    return cabinet

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

This program defines a basic rectangular cabinet with a frame, two doors, and shelves inside. Feel free to adjust the parameters or add more details as needed! Let me know if you need any modifications.