import sand3d as s3d
def bottle():
body = s3d.at(bottle_body(), z=0)
return s3d.assembly(class="tok-string">"bottle", body)
def bottle_body(h=188, base_r=31, rib_pitch=11, groove_d=2.5, foot_d=18, foot_r=17, lower_boundary=99, upper_boundary=144):
outline = s3d.poly([(0, 3), (23, 3), s3d.spline([(23, 3), (base_r, 14), (30, 40), (29, 53), (27, 60), (25, 72), (30, 96), (30, 143), (30, 151), (25, 162), (13, 180), (12, h)]), (0, h)])
body = s3d.revolve(class="tok-string">"bottle_skin", outline)
rib_frame = s3d.Frame(origin=(0, 0, 23+rib_pitch), normal=(0, -1, 0), up=(0, 0, 1))
tool = s3d.at(s3d.torus(class="tok-string">"rib_groove", d=59, d_wire=groove_d), rx=90, on=s3d.grid(nx=1, ny=3, py=rib_pitch, on=rib_frame))
body = s3d.cut(body, tool)
boundary_frame = s3d.Frame(origin=(0, 0, (lower_boundary+upper_boundary)/2), normal=(0, -1, 0), up=(0, 0, 1))
tool = s3d.at(s3d.torus(class="tok-string">"boundary_groove", d=60, d_wire=groove_d), rx=90, on=s3d.grid(nx=1, ny=2, py=upper_boundary-lower_boundary, on=boundary_frame))
body = s3d.cut(body, tool)
feet = s3d.at(s3d.sphere(class="tok-string">"rounded_foot", d=foot_d), on=s3d.ring(n=5, r=foot_r))
body = s3d.join(body, feet)
s3d.material(body, kind=class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#c9e3ec")
closure = s3d.at(cap(), z=182)
return s3d.group(class="tok-string">"bottle_body", body, closure)
def cap(d=26, h=20.9, ring_d=29.5, ring_h=2, ring_z=3):
lid = s3d.cylinder(class="tok-string">"closure", d=d, h=h)
s3d.fillet(lid, r=0.6, edges=class="tok-string">"top")
rim = s3d.at(s3d.cylinder(class="tok-string">"retaining_ring", d=ring_d, h=ring_h), z=ring_z)
s3d.fillet(rim, r=ring_h/3)
lid = s3d.join(lid, rim)
s3d.material(lid, kind=class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#e5e9ed")
return s3d.group(class="tok-string">"cap", lid)