 |
CLIP Score: 33.82
from AIDL import *
def house_with_garage_and_windows(
house_width: float = 40*feet,
house_height: float = 20*feet,
roof_height: float = 5*feet,
garage_width: float = 15*feet,
garage_height: float = 12*feet,
window_width: float = 3*feet,
window_height: float = 4*feet,
window_spacing: float = 5*feet
):
# Create the main house structure
house = Solid()
house_body = Solid()
house_roof = Solid()
house.body = house_body
house.roof = house_roof
# House Body
house_body.shape = Rectangle((0, 0), house_width, house_height)
# House Roof
roof_peak = Point(0, house_height + roof_height)
house_roof.left_side = Line(roof_peak, (-house_width/2, house_height))
house_roof.right_side = Line(roof_peak, (house_width/2, house_height))
# Add the garage
garage = Solid(shift=(-house_width/4, 0))
garage.shape = Rectangle((0, 0), garage_width, garage_height)
house.garage = garage
# Add the windows
windows = Solid()
num_windows = int(house_width // (window_width + window_spacing))
for i in range(num_windows):
x_pos = -house_width/2 + window_width/2 + i * (window_width + window_spacing)
window = Solid(shift=(x_pos, house_height/2))
window_shape = Rectangle((0, 0), window_width, window_height)
window.shape = window_shape
windows.__setattr__(f"window_{i}", window)
house.windows = windows
return house
with AIDL_2D:
model = house_with_garage_and_windows()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a architect's elevation of a residential house with garage and windows
Sure! Let's create an AIDL program to generate an architect's elevation of a residential house with a garage and windows. An architectural elevation shows the front view of the house, including features such as the roof, walls, doors, windows, and garage.
Here is a step-by-step guide on how to write the AIDL program:
### Step 1: Define the basic house structure
We'll begin by creating a basic structure for the house: the overall frame, the roof, the garage, and the windows.
Let's start by importing the necessary components from AIDL:
```python
from AIDL import *
```
### Step 2: Define design parameters
Next, we'll define the parameters for the house, such as dimensions for the house, garage, and the roof. We can also specify window sizes and positions.
```python
def house_with_garage_and_windows(
house_width: float = 40*feet,
house_height: float = 20*feet,
roof_height: float = 5*feet,
garage_width: float = 15*feet,
garage_height: float = 12*feet,
window_width: float = 3*feet,
window_height: float = 4*feet,
window_spacing: float = 5*feet
):
```
### Step 3: Create the main house structure
We'll create the main house structure with a solid rectangle for the body and a triangular shape for the roof.
```python
house = Solid()
house_body = Solid()
house_roof = Solid()
house.body = house_body
house.roof = house_roof
# House Body
house_body.shape = Rectangle((0, 0), house_width, house_height)
# House Roof
roof_peak = Point(0, house_height + roof_height)
house_roof.left_side = Line(roof_peak, (-house_width/2, house_height))
house_roof.right_side = Line(roof_peak, (house_width/2, house_height))
```
### Step 4: Add the garage
Next, we'll add the garage structure with a solid rectangle.
```python
garage = Solid(shift=(-house_width/4, 0))
garage.shape = Rectangle((0, 0), garage_width, garage_height)
house.garage = garage
```
### Step 5: Add the windows
We'll add several windows to the house. The number and positions of the windows will be based on the window width, height, and spacing.
```python
windows = Solid()
num_windows = int(house_width // (window_width + window_spacing))
for i in range(num_windows):
x_pos = -house_width/2 + window_width/2 + i * (window_width + window_spacing)
window = Rectangle((x_pos, house_height/2), window_width, window_height)
windows.segments.append(window)
house.windows = windows
```
### Step 6: Combine it all into the main function and render the model
Combining everything into the main function and solving and rendering the model:
```python
from AIDL import *
def house_with_garage_and_windows(
house_width: float = 40*feet,
house_height: float = 20*feet,
roof_height: float = 5*feet,
garage_width: float = 15*feet,
garage_height: float = 12*feet,
window_width: float = 3*feet,
window_height: float = 4*feet,
window_spacing: float = 5*feet
):
# Create the main house structure
house = Solid()
house_body = Solid()
house_roof = Solid()
house.body = house_body
house.roof = house_roof
# House Body
house_body.shape = Rectangle((0, 0), house_width, house_height)
# House Roof
roof_peak = Point(0, house_height + roof_height)
house_roof.left_side = Line(roof_peak, (-house_width/2, house_height))
house_roof.right_side = Line(roof_peak, (house_width/2, house_height))
# Add the garage
garage = Solid(shift=(-house_width/4, 0))
garage.shape = Rectangle((0, 0), garage_width, garage_height)
house.garage = garage
# Add the windows
windows = Solid()
num_windows = int(house_width // (window_width + window_spacing))
for i in range(num_windows):
x_pos = -house_width/2 + window_width/2 + i * (window_width + window_spacing)
window = Rectangle((x_pos, house_height/2), window_width, window_height)
windows.segments.append(window)
house.windows = windows
return house
with AIDL_2D:
model = house_with_garage_and_windows()
print(model.Solve())
model.Render()
```
That's it! This AIDL program should generate a 2D elevation of a residential house with a garage and multiple windows. Feel free to customize the parameters to suit your specific design requirements. If you have any feedback or changes you would like to make, please let me know!
Traceback (most recent call last):
File "/net/projects/ranalab/jz/aidl/AIDL/generation/backend.py", line 21, in dumbrun
exec(code, env)
File "", line 49, in
File "", line 42, in house_with_garage_and_windows
File "/net/projects/ranalab/jz/aidl/AIDL/structure.py", line 1242, in __getattr__
return self.bb.__getattribute__(name)
AttributeError: 'BoundingBox' object has no attribute 'segments'
I apologize for the mistake. In AIDL, we should not be using the attribute `segments` directly on a Solid structure. To correct this, we should properly add each window as a separate structure inside a solid containing all windows.
Let's correct the code accordingly:
### Step 6: Refactor window placement logic
Each window will be created as part of the `windows` Solid and positioned correctly without using `segments`.
Here is the corrected code:
```python
from AIDL import *
def house_with_garage_and_windows(
house_width: float = 40*feet,
house_height: float = 20*feet,
roof_height: float = 5*feet,
garage_width: float = 15*feet,
garage_height: float = 12*feet,
window_width: float = 3*feet,
window_height: float = 4*feet,
window_spacing: float = 5*feet
):
# Create the main house structure
house = Solid()
house_body = Solid()
house_roof = Solid()
house.body = house_body
house.roof = house_roof
# House Body
house_body.shape = Rectangle((0, 0), house_width, house_height)
# House Roof
roof_peak = Point(0, house_height + roof_height)
house_roof.left_side = Line(roof_peak, (-house_width/2, house_height))
house_roof.right_side = Line(roof_peak, (house_width/2, house_height))
# Add the garage
garage = Solid(shift=(-house_width/4, 0))
garage.shape = Rectangle((0, 0), garage_width, garage_height)
house.garage = garage
# Add the windows
windows = Solid()
num_windows = int(house_width // (window_width + window_spacing))
for i in range(num_windows):
x_pos = -house_width/2 + window_width/2 + i * (window_width + window_spacing)
window = Solid(shift=(x_pos, house_height/2))
window_shape = Rectangle((0, 0), window_width, window_height)
window.shape = window_shape
windows.__setattr__(f"window_{i}", window)
house.windows = windows
return house
with AIDL_2D:
model = house_with_garage_and_windows()
print(model.Solve())
model.Render()
```
In this corrected version, each window is represented as a separate `Solid` structure and added to the `windows` Solid. Each window's position is set via the `shift` parameter.
Please try this corrected version and let me know if it works or if there are any further issues!
|