 |
CLIP Score: 26.21
from AIDL import *
def old_school_telephone(base_width: float = 10*inches, base_height: float = 10*inches, handset_length: float = 9*inches, dial_radius: float = 2*inches):
"""
Create a model of an old-school telephone with a rectangular base, a handset,
and a rotary dial.
"""
# Create the base structure
base = Solid()
base_body = Solid()
dial_area = Hole()
base.base_body = base_body
base.dial_area = dial_area
# Define the base geometry
base_body.shape = Rectangle((0, 0), base_width, base_height)
# Define the dial area geometry
dial_area.circle = Circle((0, 0), dial_radius)
# Create the handset structure
handset = Solid(shift=(0, -base_height/2 - handset_length/2))
handset_body = Solid()
earpiece = Solid(shift=(0, handset_length/2 - 1*inch))
mouthpiece = Solid(shift=(0, -handset_length/2 + 1*inch))
handset.handset_body = handset_body
handset.earpiece = earpiece
handset.mouthpiece = mouthpiece
# Define the handset geometry
handset_body.shape = Rectangle((0, 0), 1.5*inch, handset_length)
earpiece.shape = Circle((0, 0), 1.5*inch)
mouthpiece.shape = Circle((0, 0), 1.5*inch)
base.handset = handset
# Create the cord structure as a drawing
cord = Drawing()
cord_line = Line((-base_width/2, -base_height/2), (0, -base_height/2 - handset_length + 2.5*inch))
cord.cord_line = cord_line
base.cord = cord
return 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 start by breaking down the parts of an old-school telephone that we need to create. An old-school telephone typically includes:
1. **Base**: The main body of the telephone where the dial and handset rest.
2. **Dial**: The rotary dial or keypad area.
3. **Handset**: The part you pick up, which includes the earpiece and mouthpiece.
4. **Cord**: The coiled cord connecting the handset to the base (represented as a line in 2D).
Here is how we can structure it:
1. Solid structure for the base with a rectangular shape.
2. Solid structures for the handset.
3. Hole structure for the dial area.
4. Drawing structure for the cord.
We'll keep the dimensions as parameters for flexibility. Afterwards, we'll assemble the components to create the final model:
```python
from AIDL import *
def old_school_telephone(base_width: float = 10*inches, base_height: float = 10*inches, handset_length: float = 9*inches, dial_radius: float = 2*inches):
"""
Create a model of an old-school telephone with a rectangular base, a handset,
and a rotary dial.
"""
# Create the base structure
base = Solid()
base_body = Solid()
dial_area = Hole()
base.base_body = base_body
base.dial_area = dial_area
# Define the base geometry
base_body.shape = Rectangle((0, 0), base_width, base_height)
# Define the dial area geometry
dial_area.circle = Circle((0, 0), dial_radius)
# Create the handset structure
handset = Solid(shift=(0, -base_height/2 - handset_length/2))
handset_body = Solid()
earpiece = Solid(shift=(0, handset_length/2 - 1*inch))
mouthpiece = Solid(shift=(0, -handset_length/2 + 1*inch))
handset.handset_body = handset_body
handset.earpiece = earpiece
handset.mouthpiece = mouthpiece
# Define the handset geometry
handset_body.shape = Rectangle((0, 0), 1.5*inch, handset_length)
earpiece.shape = Circle((0, 0), 1.5*inch)
mouthpiece.shape = Circle((0, 0), 1.5*inch)
base.handset = handset
# Create the cord structure as a drawing
cord = Drawing()
cord_line = Line((-base_width/2, -base_height/2), (0, -base_height/2 - handset_length + 2.5*inch))
cord.cord_line = cord_line
base.cord = cord
return base
with AIDL_2D:
model = old_school_telephone()
print(model.Solve())
model.Render()
```
This AIDL program creates an old-school telephone with a rectangular base, a rotary dial, and a handset with earpiece and mouthpiece components. The cord is represented by a line in the drawing layer. Adjust the parameters `base_width`, `base_height`, `handset_length`, and `dial_radius` to customize the sizes as needed.
If you have any specific details or additional features you'd like to add to the model, please let me know!
|