 |
CLIP Score: 25.76
from AIDL import *
def lighthouse(
base_radius: float = 2*inches,
tower_radius_bottom: float = 1.5*inches,
tower_radius_top: float = 1*inches,
tower_height: float = 8*inches,
light_chamber_radius: float = 1.25*inches,
light_chamber_height: float = 1.5*inches,
roof_height: float = 1.75*inches,
door_height: float = 1*inch,
window_radius: float = 0.25*inch):
# Base structure
lighthouse = Solid()
base = Solid()
lighthouse.base = base
# Tower structure
tower = Solid()
lighthouse.tower = tower
# Light chamber structure
light_chamber = Solid()
lighthouse.light_chamber = light_chamber
# Roof structure
roof = Solid(shift=(0, roof_height))
lighthouse.roof = roof
# Base Geometry
base.disk = Circle((0,0), base_radius)
# Tower Geometry
tower.bottom = Circle((0, 0), tower_radius_bottom)
tower.top = Circle((0, tower_height), tower_radius_top)
# Define the taper lines to connect the circles' edges
tower.left_taper = Line((tower_radius_bottom, 0), (tower_radius_top, tower_height))
tower.right_taper = Line((-tower_radius_bottom, 0), (-tower_radius_top, tower_height))
# Light Chamber Geometry
light_chamber.bottom = Circle((0,0), light_chamber_radius)
light_chamber.top = Circle((0,light_chamber_height), light_chamber_radius)
# Roof Geometry
roof.disk = Circle((0,0), light_chamber_radius)
roof.tip = Point((0, roof_height))
# Windows and Door
door = Hole()
lighthouse.door = door
door.rectangle = Rectangle((0, -base_radius + door_height / 2), door_height / 2, door_height)
windows = Hole()
lighthouse.windows = windows
window_positions = [(0, 2*inches), (1*inch, 4*inches), (-1*inch, 5.5*inches)]
windows.circles = [Circle(pos, window_radius) for pos in window_positions]
# Constraints
# Base Constraints
lighthouse.AddConstraint(base.disk.center.u == tower.bottom.center.u)
lighthouse.AddConstraint(base.disk.center.v == tower.bottom.center.v)
# Tower Constraints
lighthouse.AddConstraint(tower.top.center.u == light_chamber.bottom.center.u)
lighthouse.AddConstraint(tower.top.center.v == light_chamber.bottom.center.v - tower_height)
light_chamber.AddConstraint(light_chamber.top.center.u == light_chamber.bottom.center.u)
light_chamber.AddConstraint(light_chamber.top.center.v == light_chamber.bottom.center.v + light_chamber_height)
# Roof Constraints
roof.AddConstraint(roof.tip.u == roof.disk.center.u)
roof.AddConstraint(roof.tip.v == roof.disk.center.v + roof_height)
# Door Constraints
lighthouse.AddConstraint(door.rectangle.center.u == 0)
lighthouse.AddConstraint(door.rectangle.center.v == -base_radius + door_height / 2)
# Windows Constraints
for window in windows.circles:
windows.AddConstraint(window.center.u == window_positions[windows.circles.index(window)][0])
windows.AddConstraint(window.center.v == window_positions[windows.circles.index(window)][1])
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a lighthouse
Sure, let's start with writing an AIDL program to generate a lighthouse. This lighthouse will consist of a few basic parts:
1. **Base**: A circular base for stability.
2. **Lighthouse Tower**: A tapered cylindrical section representing the main body of the lighthouse.
3. **Light Chamber**: A circular chamber at the top where the light is housed.
4. **Roof**: A conical roof to cap the light chamber.
5. **Windows and Door**: Holes for windows and a door.
We will start by constructing the main structure and then add the individual parts step by step.
Let's break it down:
1. Define the structural elements.
2. Add geometric features to each element.
3. Set constraints to ensure everything aligns correctly.
Here’s the implementation:
```python
from AIDL import *
def lighthouse(
base_radius: float = 2*inches,
tower_radius_bottom: float = 1.5*inches,
tower_radius_top: float = 1*inches,
tower_height: float = 8*inches,
light_chamber_radius: float = 1.25*inches,
light_chamber_height: float = 1.5*inches,
roof_height: float = 1.75*inches,
door_height: float = 1*inch,
window_radius: float = 0.25*inch):
# Base structure
lighthouse = Solid()
base = Solid()
lighthouse.base = base
# Tower structure
tower = Solid()
lighthouse.tower = tower
# Light chamber structure
light_chamber = Solid()
lighthouse.light_chamber = light_chamber
# Roof structure
roof = Solid(shift=(0, roof_height))
lighthouse.roof = roof
# Base Geometry
base.disk = Circle((0,0), base_radius)
# Tower Geometry
tower.bottom = Circle((0, 0), tower_radius_bottom)
tower.top = Circle((0, tower_height), tower_radius_top)
tower.left_taper = Line(tower.bottom.center, tower.top.start)
tower.right_taper = Line(tower.bottom.center, tower.top.end)
# Light Chamber Geometry
light_chamber.bottom = Circle((0,0), light_chamber_radius)
light_chamber.top = Circle((0,light_chamber_height), light_chamber_radius)
# Roof Geometry
roof.disk = Circle((0,0), light_chamber_radius)
roof.tip = Point((0, roof_height))
# Windows and Door
door = Hole()
lighthouse.door = door
door.rectangle = Rectangle((0,-base_radius+door_height/2), door_height / 2, door_height)
windows = Hole()
lighthouse.windows = windows
window_positions = [(0,2*inches), (1*inch,4*inches), (-1*inch,5.5*inches)]
windows.circles = [Circle(pos, window_radius) for pos in window_positions]
# Constraints
# Base Constraints
lighthouse.AddConstraint(base.disk.center.u == tower.bottom.center.u)
lighthouse.AddConstraint(base.disk.center.v == tower.bottom.center.v)
# Tower Constraints
lighthouse.AddConstraint(tower.top.center.u == light_chamber.bottom.center.u)
lighthouse.AddConstraint(tower.top.center.v == light_chamber.bottom.center.v - tower_height)
light_chamber.AddConstraint(light_chamber.top.center.u == light_chamber.bottom.center.u)
light_chamber.AddConstraint(light_chamber.top.center.v == light_chamber.bottom.center.v + light_chamber_height)
# Roof Constraints
roof.AddConstraint(roof.tip.u == roof.disk.center.u)
roof.AddConstraint(roof.tip.v == roof.disk.center.v + roof_height)
# Door Constraints
lighthouse.AddConstraint(door.rectangle.center.u == 0)
lighthouse.AddConstraint(door.rectangle.center.v == -base_radius + door_height/2)
# Windows Constraints
for window in windows.circles:
windows.AddConstraint(window.center.u == window.center.u)
windows.AddConstraint(window.center.v == window.center.v)
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
This script sets up a basic lighthouse structure with a base, a tapered tower, a light chamber, a conical roof, and holes for a door and windows. Feel free to adjust the parameters for sizes and positions of different parts as needed. Let me know if you would like any modifications or additional details added to the lighthouse.
Traceback (most recent call last):
File "/net/projects/ranalab/jz/aidl/AIDL/generation/backend.py", line 21, in dumbrun
exec(code, env)
File "", line 87, in
File "", line 38, in lighthouse
AttributeError: 'Circle' object has no attribute 'start'
Thank you for pointing that out. It looks like there's a mistake with the references to the `start` and `end` attributes of circles in the taper lines of the tower. Circle objects only have a center and a radius. We should connect the tapering lines from the center of the bottom circle to the outer points by calculating the corresponding coordinates.
Let's correct the script.
Here is the revised code:
```python
from AIDL import *
def lighthouse(
base_radius: float = 2*inches,
tower_radius_bottom: float = 1.5*inches,
tower_radius_top: float = 1*inches,
tower_height: float = 8*inches,
light_chamber_radius: float = 1.25*inches,
light_chamber_height: float = 1.5*inches,
roof_height: float = 1.75*inches,
door_height: float = 1*inch,
window_radius: float = 0.25*inch):
# Base structure
lighthouse = Solid()
base = Solid()
lighthouse.base = base
# Tower structure
tower = Solid()
lighthouse.tower = tower
# Light chamber structure
light_chamber = Solid()
lighthouse.light_chamber = light_chamber
# Roof structure
roof = Solid(shift=(0, roof_height))
lighthouse.roof = roof
# Base Geometry
base.disk = Circle((0,0), base_radius)
# Tower Geometry
tower.bottom = Circle((0, 0), tower_radius_bottom)
tower.top = Circle((0, tower_height), tower_radius_top)
# Define the taper lines to connect the circles' edges
tower.left_taper = Line((tower_radius_bottom, 0), (tower_radius_top, tower_height))
tower.right_taper = Line((-tower_radius_bottom, 0), (-tower_radius_top, tower_height))
# Light Chamber Geometry
light_chamber.bottom = Circle((0,0), light_chamber_radius)
light_chamber.top = Circle((0,light_chamber_height), light_chamber_radius)
# Roof Geometry
roof.disk = Circle((0,0), light_chamber_radius)
roof.tip = Point((0, roof_height))
# Windows and Door
door = Hole()
lighthouse.door = door
door.rectangle = Rectangle((0, -base_radius + door_height / 2), door_height / 2, door_height)
windows = Hole()
lighthouse.windows = windows
window_positions = [(0, 2*inches), (1*inch, 4*inches), (-1*inch, 5.5*inches)]
windows.circles = [Circle(pos, window_radius) for pos in window_positions]
# Constraints
# Base Constraints
lighthouse.AddConstraint(base.disk.center.u == tower.bottom.center.u)
lighthouse.AddConstraint(base.disk.center.v == tower.bottom.center.v)
# Tower Constraints
lighthouse.AddConstraint(tower.top.center.u == light_chamber.bottom.center.u)
lighthouse.AddConstraint(tower.top.center.v == light_chamber.bottom.center.v - tower_height)
light_chamber.AddConstraint(light_chamber.top.center.u == light_chamber.bottom.center.u)
light_chamber.AddConstraint(light_chamber.top.center.v == light_chamber.bottom.center.v + light_chamber_height)
# Roof Constraints
roof.AddConstraint(roof.tip.u == roof.disk.center.u)
roof.AddConstraint(roof.tip.v == roof.disk.center.v + roof_height)
# Door Constraints
lighthouse.AddConstraint(door.rectangle.center.u == 0)
lighthouse.AddConstraint(door.rectangle.center.v == -base_radius + door_height / 2)
# Windows Constraints
for window in windows.circles:
windows.AddConstraint(window.center.u == window_positions[windows.circles.index(window)][0])
windows.AddConstraint(window.center.v == window_positions[windows.circles.index(window)][1])
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
This revised script correctly constructs the lines connecting the edges of the circles for the tapering tower by specifying coordinates directly. Try running it again and let me know if there are any more issues or if there's anything else you'd like to add or change.
|