 |
CLIP Score: 28.61
from AIDL import *
def old_school_telephone(
base_width: float = 8 * inches,
base_height: float = 6 * inches,
dial_diameter: float = 3 * inches,
handset_width: float = 1.5 * inches,
handset_length: float = 9 * inches,
n_dial_holes: int = 10
):
# Create the telephone model
telephone_base = Solid()
rotary_dial = Solid(shift=(0, 0.5 * base_height - 1.5 * dial_diameter))
handset = Solid(shift=(0, -0.5 * base_height))
# Define the base geometry
telephone_base.outline = RoundedRectangle((0, 0), base_width, base_height, corner_radius=1 * inch)
# Define the rotary dial geometry
rotary_dial.outer_ring = Circle((0, 0), dial_diameter / 2)
rotary_dial.holes = [Hole() for _ in range(n_dial_holes)]
for i, hole in enumerate(rotary_dial.holes):
angle = 360 / n_dial_holes * i
x = (dial_diameter / 2 - 0.4 * inch) * cos(radians(angle))
y = (dial_diameter / 2 - 0.4 * inch) * sin(radians(angle))
hole.circle = Circle((x, y), 0.3 * inch)
telephone_base.rotary_dial = rotary_dial
# Define the handset geometry
handset.body = Rectangle((0, 0), handset_length, handset_width)
handset.ear_piece = Circle((-0.4 * handset_length, 0), 0.5 * inch)
handset.mouth_piece = Circle((0.4 * handset_length, 0), 0.5 * inch)
telephone_base.handset = handset
return telephone_base
with AIDL_2D:
model = old_school_telephone()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a old-school telephone
Sure! Let's break this down step by step. An old-school telephone typically has the following parts:
1. A base with a rectangular or rounded shape.
2. A rotary dial with numbered holes.
3. A handset with ear and mouth pieces.
4. Handset's cord (optional for simplicity in 2D representation).
We'll start with the base, then create the rotary dial, and finally the handset. Let's set some basic parameters for the design:
- Base dimensions (width, height)
- Rotary dial dimensions (diameter)
- Handset dimensions (width, length)
- Number of holes in the rotary dial
#### Step 1: Define the Base
```python
from AIDL import *
def old_school_telephone(
base_width: float = 8 * inches,
base_height: float = 6 * inches,
dial_diameter: float = 3 * inches,
handset_width: float = 1.5 * inches,
handset_length: float = 9 * inches,
n_dial_holes: int = 10
):
# Create the telephone model
telephone_base = Solid()
# Define the base geometry
telephone_base.outline = RoundedRectangle((0, 0), base_width, base_height, corner_radius=1 * inch)
return telephone_base
with AIDL_2D:
model = old_school_telephone()
print(model.Solve())
model.Render()
```
#### Step 2: Add the Rotary Dial
```python
from AIDL import *
def old_school_telephone(
base_width: float = 8 * inches,
base_height: float = 6 * inches,
dial_diameter: float = 3 * inches,
handset_width: float = 1.5 * inches,
handset_length: float = 9 * inches,
n_dial_holes: int = 10
):
# Create the telephone model
telephone_base = Solid()
rotary_dial = Solid(shift=(0, 0.5 * base_height - 1.5 * dial_diameter))
# Define the base geometry
telephone_base.outline = RoundedRectangle((0, 0), base_width, base_height, corner_radius=1 * inch)
# Define the rotary dial geometry
rotary_dial.outer_ring = Circle((0, 0), dial_diameter / 2)
rotary_dial.holes = [Hole() for _ in range(n_dial_holes)]
for i, hole in enumerate(rotary_dial.holes):
angle = 360 / n_dial_holes * i
x = (dial_diameter / 2 - 0.4 * inch) * cos(radians(angle))
y = (dial_diameter / 2 - 0.4 * inch) * sin(radians(angle))
hole.circle = Circle((x, y), 0.3 * inch)
telephone_base.rotary_dial = rotary_dial
return telephone_base
with AIDL_2D:
model = old_school_telephone()
print(model.Solve())
model.Render()
```
#### Step 3: Add the Handset
```python
from AIDL import *
def old_school_telephone(
base_width: float = 8 * inches,
base_height: float = 6 * inches,
dial_diameter: float = 3 * inches,
handset_width: float = 1.5 * inches,
handset_length: float = 9 * inches,
n_dial_holes: int = 10
):
# Create the telephone model
telephone_base = Solid()
rotary_dial = Solid(shift=(0, 0.5 * base_height - 1.5 * dial_diameter))
handset = Solid(shift=(0, -0.5 * base_height))
# Define the base geometry
telephone_base.outline = RoundedRectangle((0, 0), base_width, base_height, corner_radius=1 * inch)
# Define the rotary dial geometry
rotary_dial.outer_ring = Circle((0, 0), dial_diameter / 2)
rotary_dial.holes = [Hole() for _ in range(n_dial_holes)]
for i, hole in enumerate(rotary_dial.holes):
angle = 360 / n_dial_holes * i
x = (dial_diameter / 2 - 0.4 * inch) * cos(radians(angle))
y = (dial_diameter / 2 - 0.4 * inch) * sin(radians(angle))
hole.circle = Circle((x, y), 0.3 * inch)
telephone_base.rotary_dial = rotary_dial
# Define the handset geometry
handset.body = Rectangle((0, 0), handset_length, handset_width)
handset.ear_piece = Circle((-0.4 * handset_length, 0), 0.5 * inch)
handset.mouth_piece = Circle((0.4 * handset_length, 0), 0.5 * inch)
telephone_base.handset = handset
return telephone_base
with AIDL_2D:
model = old_school_telephone()
print(model.Solve())
model.Render()
```
Here is the complete code:
```python
from AIDL import *
def old_school_telephone(
base_width: float = 8 * inches,
base_height: float = 6 * inches,
dial_diameter: float = 3 * inches,
handset_width: float = 1.5 * inches,
handset_length: float = 9 * inches,
n_dial_holes: int = 10
):
# Create the telephone model
telephone_base = Solid()
rotary_dial = Solid(shift=(0, 0.5 * base_height - 1.5 * dial_diameter))
handset = Solid(shift=(0, -0.5 * base_height))
# Define the base geometry
telephone_base.outline = RoundedRectangle((0, 0), base_width, base_height, corner_radius=1 * inch)
# Define the rotary dial geometry
rotary_dial.outer_ring = Circle((0, 0), dial_diameter / 2)
rotary_dial.holes = [Hole() for _ in range(n_dial_holes)]
for i, hole in enumerate(rotary_dial.holes):
angle = 360 / n_dial_holes * i
x = (dial_diameter / 2 - 0.4 * inch) * cos(radians(angle))
y = (dial_diameter / 2 - 0.4 * inch) * sin(radians(angle))
hole.circle = Circle((x, y), 0.3 * inch)
telephone_base.rotary_dial = rotary_dial
# Define the handset geometry
handset.body = Rectangle((0, 0), handset_length, handset_width)
handset.ear_piece = Circle((-0.4 * handset_length, 0), 0.5 * inch)
handset.mouth_piece = Circle((0.4 * handset_length, 0), 0.5 * inch)
telephone_base.handset = handset
return telephone_base
with AIDL_2D:
model = old_school_telephone()
print(model.Solve())
model.Render()
```
Please let me know if you need any modifications or additional details for the object.
|