import sand3d as s3d
def can():
body = s3d.at(can_body(), x=-1.5, y=3.3, z=-34.1)
top = s3d.at(lid(), x=-1.5, y=3.3, z=118.8)
return s3d.assembly(class="tok-string">"can", body, top)
def can_body(d=59.4, h=155, foot_d=48, foot_h=4, round_h=9, shoulder_h=6, neck_d=54, recess_h=10):
r = d / 2
solid = s3d.revolve(class="tok-string">"body", s3d.poly([(foot_d / 2, 0), (r - 1, foot_h), (r, round_h), (r, h - shoulder_h), (neck_d / 2, h), (0, h), (0, recess_h), (foot_d / 2 - 5, recess_h / 2), (foot_d / 2, 0)]))
s3d.material(solid, class="tok-string">"painted_metal", color=class="tok-string">"class="tok-comment">#242229", roughness=0.48)
return s3d.group(class="tok-string">"can_body_group", solid)
def lid(d=55, h=7, t=1, inset=3, plate_h=2.5):
r = d / 2
solid = s3d.revolve(class="tok-string">"lid", s3d.poly([(0, 0), (r - t, 0), (r, h - t), (r - t / 2, h), (r - t, h - t), (r - t, inset), (r - inset, t), (r - inset - t, plate_h), (0, plate_h)]))
s3d.material(solid, class="tok-string">"aluminium", color=class="tok-string">"class="tok-comment">#8b8389", roughness=0.4)
tab = s3d.at(pull_tab(), y=1, z=4)
return s3d.group(class="tok-string">"lid_group", solid, tab)
def pull_tab(w=16, d=27, h=2, hole_d=8, pitch=13, rivet_d=4):
solid = s3d.extrude(class="tok-string">"tab", s3d.rect(w=w, d=d, r=w / 2 - 1), h=h)
solid = s3d.hole(solid, d=hole_d, on=s3d.grid(nx=1, ny=2, py=pitch))
rivet = s3d.cylinder(class="tok-string">"rivet", d=rivet_d, h=h + 0.5)
s3d.material(solid, class="tok-string">"aluminium", color=class="tok-string">"class="tok-comment">#9d9090", roughness=0.4)
s3d.material(rivet, class="tok-string">"aluminium", color=class="tok-string">"class="tok-comment">#9d9090", roughness=0.4)
return s3d.group(class="tok-string">"pull_tab_group", solid, rivet)