 |
CLIP Score: 29.85
from AIDL import *
def cabinet(
cabinet_height: float = 36 * inches,
cabinet_width: float = 24 * inches,
cabinet_depth: float = 12 * inches,
door_count: int = 2,
shelf_count: int = 3
):
"""
Model a simple rectangular cabinet with doors and shelves
"""
cabinet = Solid()
# Define the body geometry.
body = Solid()
cabinet.body = body
body.left_side = Rectangle((-cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.right_side = Rectangle((cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.top_side = Rectangle((0, cabinet_height / 2), cabinet_width, cabinet_depth)
body.bottom_side = Rectangle((0, -cabinet_height / 2), cabinet_width, cabinet_depth)
body.back_panel = Rectangle((0, 0), cabinet_width, cabinet_height)
# Define the shelves inside the cabinet.
shelves = Solid()
cabinet.shelves = shelves
shelf_spacing = cabinet_height / (shelf_count + 1)
for i in range(1, shelf_count + 1):
shelf = Rectangle((0, cabinet_height / 2 - i * shelf_spacing), cabinet_width, cabinet_depth)
shelves.__setattr__(f"shelf_{i}", shelf)
# Define the doors.
doors = Solid()
cabinet.doors = doors
door_width = cabinet_width / door_count
for i in range(door_count):
door = Rectangle(((i - (door_count / 2 - 0.5)) * door_width, 0), door_width, cabinet_height)
doors.__setattr__(f"door_{i+1}", door)
return cabinet
with AIDL_2D:
model = cabinet()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a cabinet
Sure, let's design a basic cabinet with the following features:
- A rectangular body with some depth.
- Two doors that can open.
- Shelves inside the cabinet.
- A back panel.
To break this down:
1. We'll create the main body of the cabinet.
2. We'll add shelves inside the cabinet.
3. We'll create doors and place them correctly.
4. We'll add a back panel to the cabinet.
Let's start creating the AIDL program step-by-step. I'll begin by defining the main body of the cabinet.
### Step 1: Define the Main Body
```python
from AIDL import *
def cabinet(
cabinet_height: float = 36 * inches,
cabinet_width: float = 24 * inches,
cabinet_depth: float = 12 * inches,
door_count: int = 2,
shelf_count: int = 3
):
"""
Model a simple rectangular cabinet with doors and shelves
"""
cabinet = Solid()
# Define the body geometry.
# The body consists of sides, top, bottom, and back panels.
body = Solid()
cabinet.body = body
body.left_side = Rectangle((-cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.right_side = Rectangle((cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.top_side = Rectangle((0, cabinet_height / 2), cabinet_width, cabinet_depth)
body.bottom_side = Rectangle((0, -cabinet_height / 2), cabinet_width, cabinet_depth)
body.back_panel = Rectangle((0, 0), cabinet_width, cabinet_height)
return cabinet
with AIDL_2D:
model = cabinet()
print(model.Solve())
model.Render()
```
Next, we'll add shelves inside the cabinet.
### Step 2: Adding Shelves
```python
from AIDL import *
def cabinet(
cabinet_height: float = 36 * inches,
cabinet_width: float = 24 * inches,
cabinet_depth: float = 12 * inches,
door_count: int = 2,
shelf_count: int = 3
):
"""
Model a simple rectangular cabinet with doors and shelves
"""
cabinet = Solid()
# Define the body geometry.
body = Solid()
cabinet.body = body
body.left_side = Rectangle((-cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.right_side = Rectangle((cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.top_side = Rectangle((0, cabinet_height / 2), cabinet_width, cabinet_depth)
body.bottom_side = Rectangle((0, -cabinet_height / 2), cabinet_width, cabinet_depth)
body.back_panel = Rectangle((0, 0), cabinet_width, cabinet_height)
# Define the shelves inside the cabinet.
shelves = Solid()
cabinet.shelves = shelves
shelf_spacing = cabinet_height / (shelf_count + 1)
for i in range(1, shelf_count + 1):
shelf = Rectangle((0, cabinet_height / 2 - i * shelf_spacing), cabinet_width, cabinet_depth)
shelves.__setattr__(f"shelf_{i}", shelf)
return cabinet
with AIDL_2D:
model = cabinet()
print(model.Solve())
model.Render()
```
Next, we'll create doors for the cabinet.
### Step 3: Adding Doors
```python
from AIDL import *
def cabinet(
cabinet_height: float = 36 * inches,
cabinet_width: float = 24 * inches,
cabinet_depth: float = 12 * inches,
door_count: int = 2,
shelf_count: int = 3
):
"""
Model a simple rectangular cabinet with doors and shelves
"""
cabinet = Solid()
# Define the body geometry.
body = Solid()
cabinet.body = body
body.left_side = Rectangle((-cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.right_side = Rectangle((cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.top_side = Rectangle((0, cabinet_height / 2), cabinet_width, cabinet_depth)
body.bottom_side = Rectangle((0, -cabinet_height / 2), cabinet_width, cabinet_depth)
body.back_panel = Rectangle((0, 0), cabinet_width, cabinet_height)
# Define the shelves inside the cabinet.
shelves = Solid()
cabinet.shelves = shelves
shelf_spacing = cabinet_height / (shelf_count + 1)
for i in range(1, shelf_count + 1):
shelf = Rectangle((0, cabinet_height / 2 - i * shelf_spacing), cabinet_width, cabinet_depth)
shelves.__setattr__(f"shelf_{i}", shelf)
# Define the doors.
doors = Solid()
cabinet.doors = doors
door_width = cabinet_width / door_count
for i in range(door_count):
door = Rectangle(((i - (door_count / 2 - 0.5)) * door_width, 0), door_width, cabinet_height)
doors.__setattr__(f"door_{i+1}", door)
return cabinet
with AIDL_2D:
model = cabinet()
print(model.Solve())
model.Render()
```
Finally, we add a back panel to the cabinet.
### Step 4: Adding a Back Panel
```python
from AIDL import *
def cabinet(
cabinet_height: float = 36 * inches,
cabinet_width: float = 24 * inches,
cabinet_depth: float = 12 * inches,
door_count: int = 2,
shelf_count: int = 3
):
"""
Model a simple rectangular cabinet with doors and shelves
"""
cabinet = Solid()
# Define the body geometry.
body = Solid()
cabinet.body = body
body.left_side = Rectangle((-cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.right_side = Rectangle((cabinet_width / 2, 0), cabinet_depth, cabinet_height)
body.top_side = Rectangle((0, cabinet_height / 2), cabinet_width, cabinet_depth)
body.bottom_side = Rectangle((0, -cabinet_height / 2), cabinet_width, cabinet_depth)
body.back_panel = Rectangle((0, 0), cabinet_width, cabinet_height)
# Define the shelves inside the cabinet.
shelves = Solid()
cabinet.shelves = shelves
shelf_spacing = cabinet_height / (shelf_count + 1)
for i in range(1, shelf_count + 1):
shelf = Rectangle((0, cabinet_height / 2 - i * shelf_spacing), cabinet_width, cabinet_depth)
shelves.__setattr__(f"shelf_{i}", shelf)
# Define the doors.
doors = Solid()
cabinet.doors = doors
door_width = cabinet_width / door_count
for i in range(door_count):
door = Rectangle(((i - (door_count / 2 - 0.5)) * door_width, 0), door_width, cabinet_height)
doors.__setattr__(f"door_{i+1}", door)
return cabinet
with AIDL_2D:
model = cabinet()
print(model.Solve())
model.Render()
```
This AIDL program creates a simple cabinet model with a rectangular body, shelves, doors, and a back panel. If you have any additional details or features you'd like to add (e.g., handles, more detailed structure), please let me know, and I'll help you incorporate those into the design!
|