 |
CLIP Score: 28.5
from AIDL import *
def telephone(
base_width: float = 6 * inches,
base_height: float = 8 * inches,
handset_length: float = 10 * inches,
dial_radius: float = 2 * inches
):
"""
Model an old-school telephone with a base, handset, and rotary dial.
"""
base = Solid()
handset = Solid(shift=(0, base_height / 2 + 0.5 * inches))
dial = Solid(shift=(0, 0))
dial_holes = Hole()
# Define the base geometry. Start with a rounded rectangle for aesthetic purposes
base.body = RoundedRectangle((0,0), base_width, base_height, base_width/10)
# Define the handset geometry
handset.main_body = RoundedRectangle((0, 0), handset_length, 1.5 * inches, 0.5 * inches)
handset.left_speaker = Circle((-handset_length/2 + 0.75 * inches, 0), 0.75 * inches)
handset.right_speaker = Circle((handset_length/2 - 0.75 * inches, 0), 0.75 * inches)
base.handset = handset
# Define the dial geometry
dial.outer_ring = Circle((0, 0), dial_radius)
dial.center = Circle((0, 0), dial_radius / 2) # Central circle (the spinner part)
dial.finger_holes = dial_holes
# Define the holes for finger
num_holes = 10
angle_step = 360 / num_holes
dial_holes.holes = [Circle(
(dial_radius * cos(radians(i * angle_step)), dial_radius * sin(radians(i * angle_step))),
0.25 * inches) for i in range(num_holes)]
base.dial = dial
return base
with AIDL_2D:
model = telephone()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a old-school telephone
Got it! Let's break down the process of creating an old-school telephone using the AIDL language. For an old-school telephone, we'll typically focus on the following components:
1. **Handset** – The part of the telephone that you hold to your ear and mouth.
2. **Base** – The housing that holds the dial and supports the handset.
3. **Dial** – The rotary part used for dialing numbers.
We can break these components into separate structures and build up the model step-by-step.
First, let's start with the **Base** of the telephone. We can create a simple rectangular or rounded-rectangle base.
```python
from AIDL import *
def telephone(
base_width: float = 6 * inches,
base_height: float = 8 * inches,
handset_length: float = 10 * inches,
dial_radius: float = 2 * inches
):
"""
Model an old-school telephone with a base, handset, and rotary dial.
"""
base = Solid()
# Define the base geometry. Start with a rounded rectangle for aesthetic purposes
base.body = RoundedRectangle((0,0), base_width, base_height, base_width/10)
return base
with AIDL_2D:
model = telephone()
print(model.Solve())
model.Render()
```
Next, we'll add the **Handset** to the model. The handset will be a separate Solid structure attached to the base.
```python
from AIDL import *
def telephone(
base_width: float = 6 * inches,
base_height: float = 8 * inches,
handset_length: float = 10 * inches,
dial_radius: float = 2 * inches
):
"""
Model an old-school telephone with a base, handset, and rotary dial.
"""
base = Solid()
handset = Solid(shift=(0, base_height / 2 + 0.5 * inches))
# Define the base geometry. Start with a rounded rectangle for aesthetic purposes
base.body = RoundedRectangle((0,0), base_width, base_height, base_width/10)
# Define the handset geometry
handset.main_body = RoundedRectangle((0, 0), handset_length, 1.5 * inches, 0.5 * inches)
handset.left_speaker = Circle((-handset_length/2 + 0.75 * inches, 0), 0.75 * inches)
handset.right_speaker = Circle((handset_length/2 - 0.75 * inches, 0), 0.75 * inches)
base.handset = handset
return base
with AIDL_2D:
model = telephone()
print(model.Solve())
model.Render()
```
Finally, let's add the **Rotary Dial** in the middle of the base. This will involve a circle and several hole circles for the finger placements.
```python
from AIDL import *
def telephone(
base_width: float = 6 * inches,
base_height: float = 8 * inches,
handset_length: float = 10 * inches,
dial_radius: float = 2 * inches
):
"""
Model an old-school telephone with a base, handset, and rotary dial.
"""
base = Solid()
handset = Solid(shift=(0, base_height / 2 + 0.5 * inches))
dial = Solid(shift=(0, 0))
dial_holes = Hole()
# Define the base geometry. Start with a rounded rectangle for aesthetic purposes
base.body = RoundedRectangle((0,0), base_width, base_height, base_width/10)
# Define the handset geometry
handset.main_body = RoundedRectangle((0, 0), handset_length, 1.5 * inches, 0.5 * inches)
handset.left_speaker = Circle((-handset_length/2 + 0.75 * inches, 0), 0.75 * inches)
handset.right_speaker = Circle((handset_length/2 - 0.75 * inches, 0), 0.75 * inches)
base.handset = handset
# Define the dial geometry
dial.outer_ring = Circle((0, 0), dial_radius)
dial.center = Circle((0, 0), dial_radius / 2) # Central circle (the spinner part)
dial.finger_holes = dial_holes
# Define the holes for finger
num_holes = 10
angle_step = 360 / num_holes
dial_holes.holes = [Circle(
(dial_radius * cos(radians(i * angle_step)), dial_radius * sin(radians(i * angle_step))),
0.25 * inches) for i in range(num_holes)]
base.dial = dial
return base
with AIDL_2D:
model = telephone()
print(model.Solve())
model.Render()
```
This code creates an old-school telephone model with a base, handset, and rotary dial. Feel free to guide me further on any additional details or adjustments you would like for this model.
|