-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbottle.enaml
More file actions
91 lines (82 loc) · 3.23 KB
/
bottle.enaml
File metadata and controls
91 lines (82 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"""
See https://dev.opencascade.org/doc/overview/html/occt__tutorial.html
for more details on how this works.
"""
from math import pi
from declaracad.occ.api import *
enamldef Assembly(Part): part:
name = "Bottle"
#: "Parametric" properties of this shape
attr height = 70.0
attr width = 50.0
attr thickness = 30.0
func make_cylinder_surface(**kwargs):
cylinder = Cylinder(**kwargs)
cylinder.render()
return cylinder.topology.faces[0]
Fuse:
color = '#abc'
transparency = 0.4
ThickSolid: bottle:
# Hollows out the bottle
faces << [neck.topology.faces[1]]
offset << thickness/50.0
Fuse:
# Fuse the bottle to the neck
Cylinder: neck:
# Bottle neck
position << (0,0, part.height)
direction = (0,0,1)
radius << thickness/4.0
height << part.height/10.0
Fillet: body:
# Bottle, with filleted edges
radius << thickness/12.0
Prism:
# Create a solid from the bottle face
vector << (0,0,height)
Face:
# Create a face from the base profile
Wire:
# Create a wire from the profile and mirrored profile
Wire: profile:
Segment: s1:
points << [ (-width/2.0, 0, 0), (-width/2.0, -thickness/4.0, 0)]
Arc:
points = [s1.points[-1],
(0, -thickness/2.0, 0) ,
s2.points[-1]]
Segment: s2:
points = [(width/2.0, 0, 0), (width/2.0, -thickness/4.0, 0) ]
Transform:
#: TODO coerce
operations = [Mirror(x=1)]
shape = profile
ThruSections: threads:
solid = True
Wire: w1:
attr r = neck.radius + bottle.offset
TrimmedCurve: c1:
surface = make_cylinder_surface(radius=r*0.99, position=neck.position)
v = pi
Ellipse: e1:
position = (2*pi, neck.height/2)
rotation = (pi/8, neck.height/4)
major_radius = 3*pi
minor_radius = neck.height / 10
Segment: s3:
surface = c1.surface
points = [e1.get_value_at(0), e1.get_value_at(pi)]
Wire:
color = 'green'
TrimmedCurve: c2:
surface = make_cylinder_surface(radius=w1.r*1.05, position=neck.position)
v = pi
Ellipse: e2:
position = e1.position
rotation = e1.rotation
major_radius = e1.major_radius
minor_radius = e1.minor_radius/4
Segment: s4:
surface = c2.surface
points = [e2.get_value_at(0), e2.get_value_at(pi)]