 |
CLIP Score: 30.3
from AIDL import *
def sofa_segment(width: float = 2*feet,
height: float = 3*feet,
depth: float = 2*feet):
"""
Creates a single segment of the sofa
"""
# Structure for the sofa segment
segment = Solid()
back = Solid(shift=(0, height/2))
seat = Solid()
# Geometry
back.panel = Rectangle((0,0), width, height)
seat.panel = Rectangle((0,-height/4), width, depth)
segment.back = back
segment.seat = seat
return segment
def x_shaped_sofa(segment_width: float = 2*feet,
segment_height: float = 3*feet,
segment_depth: float = 2*feet):
"""
Creates an X-shaped sofa by joining 4 segments
"""
sofa = Assembly()
# Define the individual segments
sofa.segment_1 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_2 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_3 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_4 = sofa_segment(segment_width, segment_height, segment_depth)
# Position the segments to create the X shape
angle_offset = 45 # Degrees rotation
distance_offset = (segment_width + segment_depth) / 2
sofa.segment_1.shift = (distance_offset, distance_offset)
sofa.segment_2.shift = (distance_offset, -distance_offset)
sofa.segment_3.shift = (-distance_offset, -distance_offset)
sofa.segment_4.shift = (-distance_offset, distance_offset)
return sofa
# Solve and Render
with AIDL_2D:
model = x_shaped_sofa()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a aerial view of X-shaped sofa
Sure, let's break down the task to create an AIDL program for an X-shaped sofa using laser cutting. We'll model the individual segments of the sofa and then combine them in a structure that represents the overall design.
Each segment will be made up of simple rectangular pieces, and we can use assembly nodes to put everything together into an X shape. The details can be adjusted based on specific design characteristics you have in mind.
### Step 1: Define the Basic Sofa Unit
We'll start by defining a simple sofa unit, which will later be used to create one arm of the X-shape. The unit will consist of a rectangular base and back.
```python
from AIDL import *
def sofa_segment(width: float = 2*feet,
height: float = 3*feet,
depth: float = 2*feet):
"""
Creates a single segment of the sofa
"""
# Structure for the sofa segment
segment = Solid()
back = Solid(shift=(0, height/2))
seat = Solid()
# Geometry
back.panel = Rectangle((0,0), width, height)
seat.panel = Rectangle((0,-height/4), width, depth)
segment.back = back
segment.seat = seat
return segment
```
### Step 2: Assembling the X-Shaped Sofa
Next, we'll assemble four of these segments into an X shape. Each segment will be rotated by 45 degrees and positioned relative to the center.
```python
from AIDL import *
def x_shaped_sofa(segment_width: float = 2*feet,
segment_height: float = 3*feet,
segment_depth: float = 2*feet):
"""
Creates an X-shaped sofa by joining 4 segments
"""
sofa = Assembly()
# Define the individual segments
sofa.segment_1 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_2 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_3 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_4 = sofa_segment(segment_width, segment_height, segment_depth)
# Position the segments to create the X shape
angle_offset = 45 # Degrees rotation
distance_offset = (segment_width + segment_depth) / 2
sofa.segment_1.shift = (distance_offset, distance_offset)
sofa.segment_2.shift = (distance_offset, -distance_offset)
sofa.segment_3.shift = (-distance_offset, -distance_offset)
sofa.segment_4.shift = (-distance_offset, distance_offset)
return sofa
```
### Step 3: Solve and Render the Model
Finally, let's combine everything with the solving and rendering steps.
```python
from AIDL import *
def sofa_segment(width: float = 2*feet,
height: float = 3*feet,
depth: float = 2*feet):
"""
Creates a single segment of the sofa
"""
# Structure for the sofa segment
segment = Solid()
back = Solid(shift=(0, height/2))
seat = Solid()
# Geometry
back.panel = Rectangle((0,0), width, height)
seat.panel = Rectangle((0,-height/4), width, depth)
segment.back = back
segment.seat = seat
return segment
def x_shaped_sofa(segment_width: float = 2*feet,
segment_height: float = 3*feet,
segment_depth: float = 2*feet):
"""
Creates an X-shaped sofa by joining 4 segments
"""
sofa = Assembly()
# Define the individual segments
sofa.segment_1 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_2 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_3 = sofa_segment(segment_width, segment_height, segment_depth)
sofa.segment_4 = sofa_segment(segment_width, segment_height, segment_depth)
# Position the segments to create the X shape
angle_offset = 45 # Degrees rotation
distance_offset = (segment_width + segment_depth) / 2
sofa.segment_1.shift = (distance_offset, distance_offset)
sofa.segment_2.shift = (distance_offset, -distance_offset)
sofa.segment_3.shift = (-distance_offset, -distance_offset)
sofa.segment_4.shift = (-distance_offset, distance_offset)
return sofa
# Solve and Render
with AIDL_2D:
model = x_shaped_sofa()
print(model.Solve())
model.Render()
```
This basic shape can be further detailed with more geometry, such as armrests or cushions, but this serves as the foundational structure for an X-shaped sofa. Let me know if there are specific customizations or details you would like to add!
|