 |
CLIP Score: 34.36
from AIDL import *
def house_elevation(
house_width: float = 10000, # 10 meters = 10000 millimeters
house_height: float = 6000, # 6 meters = 6000 millimeters
roof_height: float = 2000, # 2 meters = 2000 millimeters
garage_width: float = 3000, # 3 meters = 3000 millimeters
garage_height: float = 2500, # 2.5 meters = 2500 millimeters
window_width: float = 1000, # 1 meter = 1000 millimeters
window_height: float = 1000, # 1 meter = 1000 millimeters
window_spacing: float = 1000 # 1 meter = 1000 millimeters
):
"""
Model an architect's elevation of a residential house with a garage and windows.
"""
# Define the house elevation structure with subparts for house, garage, roof, and windows
house = Solid()
house_body = Solid()
garage = Solid(shift=(-house_width / 2 + garage_width / 2, 0)) # Position garage on the left
roof = Solid()
windows = [Solid(shift=(-house_width / 2 + (i + 1) * (window_width + window_spacing), 1500)) for i in range(4)]
house.house_body = house_body
house.garage = garage
house.roof = roof
house.windows = windows
# Define the house body geometry
house_body.rect = Rectangle((0, 0), house_width, house_height)
# Define the roof geometry
roof.triangle = Triangle((0, house_height), house_width, roof_height)
# Define the garage geometry
garage.rect = Rectangle((0, 0), garage_width, garage_height)
# Define the window geometry for each window
for window in windows:
window.rect = Rectangle((0, 0), window_width, window_height)
# Add Constraints
# Center roof horizontally with house body and place it on top
house.AddConstraint(roof.bb.horizontal_center == house_body.bb.horizontal_center)
house.AddConstraint(roof.bb.bottom == house_body.bb.top)
# Place garage vertically aligned with the bottom of the house
house.AddConstraint(garage.bb.bottom == house_body.bb.bottom)
# Horizontally align windows with the house body
for window in windows:
house.AddConstraint(window.bb.bottom >= house_body.bb.bottom + window_height)
return house
with AIDL_2D:
model = house_elevation()
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 start with a simple outline. We'll build a model for the architect's elevation of a residential house with a garage and windows. We'll break the elevation into several parts: the main house body, roof, garage, and windows.
The process will include creating the structure nodes, adding geometry to outline the house, roof, garage, and windows, and applying constraints to position and size them correctly.
### Step 1: Define the Structure and Hierarchical Relationships
First, we'll set up the main skeleton of the house elevation with hierarchical relationships between the structures.
```python
from AIDL import *
def house_elevation(
house_width: float = 10 * meters,
house_height: float = 6 * meters,
roof_height: float = 2 * meters,
garage_width: float = 3 * meters,
garage_height: float = 2.5 * meters,
window_width: float = 1 * meters,
window_height: float = 1 * meters,
window_spacing: float = 1 * meters):
"""
Model an architect's elevation of a residential house with a garage and windows.
"""
# Define the house elevation structure with subparts for house, garage, roof, and windows
house = Solid()
house_body = Solid()
garage = Solid()
roof = Solid()
windows = [Solid(shift=((i + 1) * (window_width + window_spacing), window_height)) for i in range(4)]
house.house_body = house_body
house.garage = garage
house.roof = roof
house.windows = windows
# Return the main house structure
return house
```
### Step 2: Add Geometric Elements
Next, let's add geometry elements to outline the house body, roof, garage, and windows:
```python
def house_elevation(
house_width: float = 10 * meters,
house_height: float = 6 * meters,
roof_height: float = 2 * meters,
garage_width: float = 3 * meters,
garage_height: float = 2.5 * meters,
window_width: float = 1 * meters,
window_height: float = 1 * meters,
window_spacing: float = 1 * meters):
"""
Model an architect's elevation of a residential house with a garage and windows.
"""
# Define the house elevation structure with subparts for house, garage, roof, and windows
house = Solid()
house_body = Solid()
garage = Solid()
roof = Solid()
windows = [Solid(shift=((i + 1) * (window_width + window_spacing), window_height)) for i in range(4)]
house.house_body = house_body
house.garage = garage
house.roof = roof
house.windows = windows
# Define the house body geometry
house_body.rect = Rectangle((0, 0), house_width, house_height)
# Define the roof geometry
roof.triangle = Triangle((0, house_height), house_width, roof_height)
# Define the garage geometry
garage.rect = Rectangle((0, 0), garage_width, garage_height)
# Define the window geometry for each window
for window in windows:
window.rect = Rectangle((0, 0), window_width, window_height)
# Return the main house structure
return house
```
### Step 3: Add Constraints
Now let's add constraints to position and scale the geometry correctly relative to each other.
```python
def house_elevation(
house_width: float = 10 * meters,
house_height: float = 6 * meters,
roof_height: float = 2 * meters,
garage_width: float = 3 * meters,
garage_height: float = 2.5 * meters,
window_width: float = 1 * meters,
window_height: float = 1 * meters,
window_spacing: float = 1 * meters):
"""
Model an architect's elevation of a residential house with a garage and windows.
"""
# Define the house elevation structure with subparts for house, garage, roof, and windows
house = Solid()
house_body = Solid()
garage = Solid(shift=(-house_width / 2 + garage_width / 2, 0)) # Position garage on the left
roof = Solid()
windows = [Solid(shift=(-house_width / 2 + (i + 1) * (window_width + window_spacing), 0)) for i in range(4)]
house.house_body = house_body
house.garage = garage
house.roof = roof
house.windows = windows
# Define the house body geometry
house_body.rect = Rectangle((0, 0), house_width, house_height)
# Define the roof geometry
roof.triangle = Triangle((0, house_height), house_width, roof_height)
# Define the garage geometry
garage.rect = Rectangle((0, 0), garage_width, garage_height)
# Define the window geometry for each window
for window in windows:
window.rect = Rectangle((0, 0), window_width, window_height)
# Add Constraints
# Center roof horizontally with house body and place it on top
house.AddConstraint(roof.bb.horizontal_center == house_body.bb.horizontal_center)
house.AddConstraint(roof.bb.bottom == house_body.bb.top)
# Place garage vertically aligned with the bottom of the house
house.AddConstraint(garage.bb.bottom == house_body.bb.bottom)
# Horizontally align windows with the house body
for window in windows:
house.AddConstraint(window.bb.bottom >= house_body.bb.bottom + window_height)
return house
```
### Step 4: Solve and Render
Finally, solve and render the model.
```python
with AIDL_2D:
model = house_elevation()
print(model.Solve())
model.Render()
```
Combining everything together, we have the complete code:
```python
from AIDL import *
def house_elevation(
house_width: float = 10 * meters,
house_height: float = 6 * meters,
roof_height: float = 2 * meters,
garage_width: float = 3 * meters,
garage_height: float = 2.5 * meters,
window_width: float = 1 * meters,
window_height: float = 1 * meters,
window_spacing: float = 1 * meters):
"""
Model an architect's elevation of a residential house with a garage and windows.
"""
# Define the house elevation structure with subparts for house, garage, roof, and windows
house = Solid()
house_body = Solid()
garage = Solid(shift=(-house_width / 2 + garage_width / 2, 0)) # Position garage on the left
roof = Solid()
windows = [Solid(shift=(-house_width / 2 + (i + 1) * (window_width + window_spacing), 0)) for i in range(4)]
house.house_body = house_body
house.garage = garage
house.roof = roof
house.windows = windows
# Define the house body geometry
house_body.rect = Rectangle((0, 0), house_width, house_height)
# Define the roof geometry
roof.triangle = Triangle((0, house_height), house_width, roof_height)
# Define the garage geometry
garage.rect = Rectangle((0, 0), garage_width, garage_height)
# Define the window geometry for each window
for window in windows:
window.rect = Rectangle((0, 0), window_width, window_height)
# Add Constraints
# Center roof horizontally with house body and place it on top
house.AddConstraint(roof.bb.horizontal_center == house_body.bb.horizontal_center)
house.AddConstraint(roof.bb.bottom == house_body.bb.top)
# Place garage vertically aligned with the bottom of the house
house.AddConstraint(garage.bb.bottom == house_body.bb.bottom)
# Horizontally align windows with the house body
for window in windows:
house.AddConstraint(window.bb.bottom >= house_body.bb.bottom + window_height)
return house
with AIDL_2D:
model = house_elevation()
print(model.Solve())
model.Render()
```
This model represents a simple elevation view of a house with a garage and windows. Let me know if you need any modifications or additional features!
Traceback (most recent call last):
File "/net/projects/ranalab/jz/aidl/AIDL/generation/backend.py", line 21, in dumbrun
exec(code, env)
File "", line 5, in
NameError: name 'meters' is not defined
Ah, I see the issue. We need to define the units for the dimensions. Let's use a standard unit, such as millimeters, for simplicity. We'll replace `meters` with `mm`.
Here's the updated version of the code with dimensions in millimeters:
```python
from AIDL import *
def house_elevation(
house_width: float = 10000, # 10 meters = 10000 millimeters
house_height: float = 6000, # 6 meters = 6000 millimeters
roof_height: float = 2000, # 2 meters = 2000 millimeters
garage_width: float = 3000, # 3 meters = 3000 millimeters
garage_height: float = 2500, # 2.5 meters = 2500 millimeters
window_width: float = 1000, # 1 meter = 1000 millimeters
window_height: float = 1000, # 1 meter = 1000 millimeters
window_spacing: float = 1000 # 1 meter = 1000 millimeters
):
"""
Model an architect's elevation of a residential house with a garage and windows.
"""
# Define the house elevation structure with subparts for house, garage, roof, and windows
house = Solid()
house_body = Solid()
garage = Solid(shift=(-house_width / 2 + garage_width / 2, 0)) # Position garage on the left
roof = Solid()
windows = [Solid(shift=(-house_width / 2 + (i + 1) * (window_width + window_spacing), 1500)) for i in range(4)]
house.house_body = house_body
house.garage = garage
house.roof = roof
house.windows = windows
# Define the house body geometry
house_body.rect = Rectangle((0, 0), house_width, house_height)
# Define the roof geometry
roof.triangle = Triangle((0, house_height), house_width, roof_height)
# Define the garage geometry
garage.rect = Rectangle((0, 0), garage_width, garage_height)
# Define the window geometry for each window
for window in windows:
window.rect = Rectangle((0, 0), window_width, window_height)
# Add Constraints
# Center roof horizontally with house body and place it on top
house.AddConstraint(roof.bb.horizontal_center == house_body.bb.horizontal_center)
house.AddConstraint(roof.bb.bottom == house_body.bb.top)
# Place garage vertically aligned with the bottom of the house
house.AddConstraint(garage.bb.bottom == house_body.bb.bottom)
# Horizontally align windows with the house body
for window in windows:
house.AddConstraint(window.bb.bottom >= house_body.bb.bottom + window_height)
return house
with AIDL_2D:
model = house_elevation()
print(model.Solve())
model.Render()
```
This should resolve the `NameError` related to `meters` being undefined by using millimeters directly. Please execute the code again and let me know if there are any further issues or if you need additional modifications.
|