 |
CLIP Score: 29.49
from AIDL import *
def macbook_chair(
base_width: float = 10 * inches,
base_length: float = 12 * inches,
back_height: float = 8 * inches,
back_angle: float = 75,
thickness: float = 0.5 * inches
):
"""
Model a simple MacBook chair with a base and a supporting back.
"""
# Define the main structure. It consists of the base plate and the back support.
chair = Assembly()
base = Solid()
back_support = Solid(shift=(0, base_length))
chair.base = base
chair.back_support = back_support
# Define the base geometry. A simple rectangle with two holes for cable management.
base.plate = Rectangle((0, 0), base_width, base_length, True)
base.hole1 = Hole()
base.hole1.shape = Circle((-base_width / 4, 0), thickness)
base.hole2 = Hole()
base.hole2.shape = Circle((base_width / 4, 0), thickness)
# Define the back support geometry as a rotated rectangle
back_plate_height = back_height / cos(radians(90 - back_angle))
back_support.plate = Rectangle((0, back_plate_height/2), base_width, back_plate_height, True)
# Define cutout for the back support where the MacBook will sit
back_support.hole = Hole()
cutout_width = base_width - thickness * 2
back_support.hole.guide = Rectangle((0, 0), cutout_width, thickness, True)
return chair
with AIDL_2D:
model = macbook_chair()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a macbook chair
Sure, let's design a simplified stand (chair) for a MacBook. The stand will have a base and a supporting back that holds the MacBook at an ergonomic angle. We'll use basic geometrical shapes like rectangles and arcs to piece together the structure.
Here's the AIDL program for a MacBook chair:
```python
from AIDL import *
def macbook_chair(
base_width: float = 10 * inches,
base_length: float = 12 * inches,
back_height: float = 8 * inches,
back_angle: float = 75,
thickness: float = 0.5 * inches
):
"""
Model a simple MacBook chair with a base and a supporting back.
"""
# Define the main structure. It consists of the base plate and the back support.
chair = Assembly()
base = Solid()
back_support = Solid(shift=(base_length / 2, -base_length / 2))
chair.base = base
chair.back_support = back_support
# Define the base geometry. A simple rectangle with two holes for cable management.
base.plate = RoundedRectangle((0, 0), base_width, base_length, thickness / 2)
base.hole1 = Hole()
base.hole1.shape = Circle((-base_width / 4, 0), thickness)
base.hole2 = Hole()
base.hole2.shape = Circle((base_width / 4, 0), thickness)
# Define the back support geometry
back_plate_height = back_height / cos(radians(back_angle))
back_support.left_edge = Line((-base_width / 4, 0), (-base_width / 4, back_plate_height)).rotate(center=(0, 0), angle=-back_angle)
back_support.right_edge = Line((base_width / 4, 0), (base_width / 4, back_plate_height)).rotate(center=(0, 0), angle=-back_angle)
back_support.top_edge = Line(back_support.left_edge.end, back_support.right_edge.end)
back_support.bottom_edge = Line(back_support.left_edge.start, back_support.right_edge.start)
# Define cutout for the back support where the MacBook will sit
back_support.hole = Hole()
back_support.hole.guide = Rectangle(back_support.top_edge.midpoint, base_width / 2, -2 * thickness).rotate(center=back_support.top_edge.midpoint, angle=-back_angle)
return chair
with AIDL_2D:
model = macbook_chair()
print(model.Solve())
model.Render()
```
This model creates a simplified version of a MacBook chair with a baseplate and a back support. Adjust the parameters like `base_width`, `base_length`, `back_height`, `back_angle`, and `thickness` according to your specific requirements.
Please let me know if you need any modifications or have any specific design details you would like to add.
Traceback (most recent call last):
File "/net/projects/ranalab/jz/aidl/AIDL/generation/backend.py", line 21, in dumbrun
exec(code, env)
File "", line 44, in
File "", line 32, in macbook_chair
AttributeError: 'Line' object has no attribute 'rotate'
It looks like I made an error by attempting to use a `rotate` method on a `Line` object, which does not exist in the given AIDL language description.
Let's simplify the back support by defining it directly with the required translation, avoiding the need to rotate our lines.
Here's the corrected version of the AIDL program that should work without the rotation:
```python
from AIDL import *
def macbook_chair(
base_width: float = 10 * inches,
base_length: float = 12 * inches,
back_height: float = 8 * inches,
back_angle: float = 75,
thickness: float = 0.5 * inches
):
"""
Model a simple MacBook chair with a base and a supporting back.
"""
# Define the main structure. It consists of the base plate and the back support.
chair = Assembly()
base = Solid()
back_support = Solid(shift=(0, base_length))
chair.base = base
chair.back_support = back_support
# Define the base geometry. A simple rectangle with two holes for cable management.
base.plate = Rectangle((0, 0), base_width, base_length, True)
base.hole1 = Hole()
base.hole1.shape = Circle((-base_width / 4, 0), thickness)
base.hole2 = Hole()
base.hole2.shape = Circle((base_width / 4, 0), thickness)
# Define the back support geometry as a rotated rectangle
back_plate_height = back_height / cos(radians(90 - back_angle))
back_support.plate = Rectangle((0, back_plate_height/2), base_width, back_plate_height, True)
# Define cutout for the back support where the MacBook will sit
back_support.hole = Hole()
cutout_width = base_width - thickness * 2
back_support.hole.guide = Rectangle((0, 0), cutout_width, thickness, True)
return chair
with AIDL_2D:
model = macbook_chair()
print(model.Solve())
model.Render()
```
In this code, we:
1. Fix the `back_support` by directly defining the height based on a calculated back plate height.
2. Simplify the geometry definitions to use direct translations.
Now the model should render correctly without any invalid method calls. Let me know if you encounter any other issues or need any additional features!
|