 |
CLIP Score: 29.22
from AIDL import *
def fountain_pen(body_length=5*inches, body_radius=0.3*inches, cap_length=2.5*inches):
pen = Solid()
cap = Solid(shift=(0, body_length - cap_length))
body = Solid()
grip = Solid(shift=(0, body_length - 0.5*inches))
nib = Solid(shift=(0, body_length))
pen.cap = cap
pen.body = body
pen.grip = grip
pen.nib = nib
# Define the body
body.body_shape = RoundedRectangle((0, 0), 2*body_radius, body_length, body_radius)
# Define the cap
cap.cap_shape = RoundedRectangle((0, 0), 2*body_radius, cap_length, body_radius)
# Define the grip
grip.grip_shape = Rectangle((0, 0), 2*body_radius * 0.9, 0.5*inches)
# Define the nib
nib.nib_shape = Triangle((0, 0), base_width=2*body_radius * 0.7, height=0.5*inches)
return pen
with AIDL_2D:
model = fountain_pen()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a fountain pen
Sure, let's go step-by-step to design a fountain pen using the AIDL language.
### Step 1: Define the Pen's Structure
We'll start by defining the main Solid nodes that make up the pen: the Body, the Grip, the Nib, and the Cap.
```python
from AIDL import *
def fountain_pen(body_length=5*inches, body_radius=0.3*inches, cap_length=2.5*inches):
pen = Solid()
cap = Solid(shift=(0, body_length - cap_length))
body = Solid()
grip = Solid(shift=(0, body_length - 0.5*inches))
nib = Solid(shift=(0, body_length))
pen.cap = cap
pen.body = body
pen.grip = grip
pen.nib = nib
return pen
with AIDL_2D:
model = fountain_pen()
print(model.Solve())
model.Render()
```
### Step 2: Define the Body Geometry
We'll add a RoundedRectangle to represent the cylindrical body of the pen.
```python
def fountain_pen(body_length=5*inches, body_radius=0.3*inches, cap_length=2.5*inches):
pen = Solid()
cap = Solid(shift=(0, body_length - cap_length))
body = Solid()
grip = Solid(shift=(0, body_length - 0.5*inches))
nib = Solid(shift=(0, body_length))
pen.cap = cap
pen.body = body
pen.grip = grip
pen.nib = nib
# Define the body
body.body_shape = RoundedRectangle((0, 0), 2*body_radius, body_length, body_radius)
return pen
with AIDL_2D:
model = fountain_pen()
print(model.Solve())
model.Render()
```
### Step 3: Define the Cap Geometry
Similarly, we'll add a geometry for the cap.
```python
def fountain_pen(body_length=5*inches, body_radius=0.3*inches, cap_length=2.5*inches):
pen = Solid()
cap = Solid(shift=(0, body_length - cap_length))
body = Solid()
grip = Solid(shift=(0, body_length - 0.5*inches))
nib = Solid(shift=(0, body_length))
pen.cap = cap
pen.body = body
pen.grip = grip
pen.nib = nib
# Define the body
body.body_shape = RoundedRectangle((0, 0), 2*body_radius, body_length, body_radius)
# Define the cap
cap.cap_shape = RoundedRectangle((0, 0), 2*body_radius, cap_length, body_radius)
return pen
with AIDL_2D:
model = fountain_pen()
print(model.Solve())
model.Render()
```
### Step 4: Define the Grip Geometry
We'll need a slight taper on the grip; let's represent that using a slightly smaller rectangle towards the top:
```python
def fountain_pen(body_length=5*inches, body_radius=0.3*inches, cap_length=2.5*inches):
pen = Solid()
cap = Solid(shift=(0, body_length - cap_length))
body = Solid()
grip = Solid(shift=(0, body_length - 0.5*inches))
nib = Solid(shift=(0, body_length))
pen.cap = cap
pen.body = body
pen.grip = grip
pen.nib = nib
# Define the body
body.body_shape = RoundedRectangle((0, 0), 2*body_radius, body_length, body_radius)
# Define the cap
cap.cap_shape = RoundedRectangle((0, 0), 2*body_radius, cap_length, body_radius)
# Define the grip
grip.grip_shape = Rectangle((0, 0), 2*body_radius * 0.9, 0.5*inches)
return pen
with AIDL_2D:
model = fountain_pen()
print(model.Solve())
model.Render()
```
### Step 5: Define the Nib Geometry
Finally, the nib of the pen can be represented as a triangular shape.
```python
def fountain_pen(body_length=5*inches, body_radius=0.3*inches, cap_length=2.5*inches):
pen = Solid()
cap = Solid(shift=(0, body_length - cap_length))
body = Solid()
grip = Solid(shift=(0, body_length - 0.5*inches))
nib = Solid(shift=(0, body_length))
pen.cap = cap
pen.body = body
pen.grip = grip
pen.nib = nib
# Define the body
body.body_shape = RoundedRectangle((0, 0), 2*body_radius, body_length, body_radius)
# Define the cap
cap.cap_shape = RoundedRectangle((0, 0), 2*body_radius, cap_length, body_radius)
# Define the grip
grip.grip_shape = Rectangle((0, 0), 2*body_radius * 0.9, 0.5*inches)
# Define the nib
nib.nib_shape = Triangle((0, 0), base_width=2*body_radius * 0.7, height=0.5*inches)
return pen
with AIDL_2D:
model = fountain_pen()
print(model.Solve())
model.Render()
```
### Step 6: Adding Details (Optional)
You can add further details using Drawing nodes if you want to include decorative lines or branding. For now, this is a basic model of a fountain pen.
### Final Version:
```python
from AIDL import *
def fountain_pen(body_length=5*inches, body_radius=0.3*inches, cap_length=2.5*inches):
pen = Solid()
cap = Solid(shift=(0, body_length - cap_length))
body = Solid()
grip = Solid(shift=(0, body_length - 0.5*inches))
nib = Solid(shift=(0, body_length))
pen.cap = cap
pen.body = body
pen.grip = grip
pen.nib = nib
# Define the body
body.body_shape = RoundedRectangle((0, 0), 2*body_radius, body_length, body_radius)
# Define the cap
cap.cap_shape = RoundedRectangle((0, 0), 2*body_radius, cap_length, body_radius)
# Define the grip
grip.grip_shape = Rectangle((0, 0), 2*body_radius * 0.9, 0.5*inches)
# Define the nib
nib.nib_shape = Triangle((0, 0), base_width=2*body_radius * 0.7, height=0.5*inches)
return pen
with AIDL_2D:
model = fountain_pen()
print(model.Solve())
model.Render()
```
Let me know if you need any more details or customization for this model!
|