import sand3d as s3d
def bin():
root = s3d.at(bin_housing(), z=0)
return s3d.assembly(class="tok-string">"bin", root)
def bin_housing(w=370, d=350, base=15, shoulder=595, rim_w=384, rim_d=364, rim_h=34, roof_base=628, eave=650, peak=848.3, ridge_r=30, corner=20, wall=4, aperture_w=264, aperture_d=258, aperture_z=712):
body = s3d.extrude(class="tok-string">"body", s3d.rect(w=w, d=d, r=corner), h=shoulder-base)
body = s3d.at(body, z=base)
body = s3d.pocket(body, s3d.rect(w=w-wall*2, d=d-wall*2, r=corner-wall), depth=26, on=body.face(class="tok-string">"bottom"))
body = s3d.pocket(body, s3d.rect(w=w-wall*2, d=d-wall*2, r=corner-wall), depth=shoulder-45, on=body.face(class="tok-string">"top"))
rim = s3d.extrude(class="tok-string">"rim", s3d.rect(w=rim_w, d=rim_d, r=corner+7), h=rim_h)
rim = s3d.fillet(rim, r=8, edges=class="tok-string">"top bottom")
rim = s3d.pocket(rim, s3d.rect(w=w-wall*2, d=d-wall*2, r=corner-wall), on=rim.face(class="tok-string">"top"))
rim = s3d.at(rim, z=shoulder)
profile = s3d.poly([(-w/2,0), (w/2,0), (w/2,eave-roof_base), s3d.arc(center=(0,peak-roof_base-ridge_r), r=ridge_r, start=40, end=140), (-w/2,eave-roof_base)])
hood = s3d.extrude(class="tok-string">"hood", profile, h=d)
hood = s3d.fillet(hood, r=12, edges=class="tok-string">"top bottom")
cavity = s3d.poly([(-w/2+wall,-wall), (w/2-wall,-wall), (w/2-wall,eave-roof_base), s3d.arc(center=(0,peak-roof_base-ridge_r), r=ridge_r-wall, start=40, end=140), (-w/2+wall,eave-roof_base)])
inside = s3d.at(s3d.extrude(class="tok-string">"hood_inside", cavity, h=d-wall*2), z=wall)
hood = s3d.cut(hood, inside)
hood = s3d.at(hood, y=d/2, z=roof_base, rx=90)
opening = s3d.at(s3d.box(class="tok-string">"opening", w=aperture_w, d=aperture_d, h=peak-aperture_z+wall), z=aperture_z)
hood = s3d.cut(hood, opening)
s3d.material(body, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#414748")
s3d.material(rim, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#343a3b")
s3d.material(hood, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#414748")
parent = s3d.group(class="tok-string">"housing", body, rim, hood)
broad = s3d.at(broad_inner_flap(), x=81.5, z=576)
narrow = s3d.at(narrow_inner_flap(), x=-76.5, z=576)
lid = s3d.at(swing_lid(), z=712)
s3d.joint(class="tok-string">"joint_body_03_joint_00", broad, on=s3d.local(parent, x=0, y=0, z=586), kind=class="tok-string">"revolute", axis=class="tok-string">"+Y", range=(-90,0))
s3d.joint(class="tok-string">"joint_body_02_joint_00", narrow, on=s3d.local(parent, x=0, y=0, z=586), kind=class="tok-string">"revolute", axis=class="tok-string">"+Y", range=(0,90))
s3d.joint(class="tok-string">"joint_lid_01_joint_00", lid, on=s3d.local(parent, x=0, y=0, z=818), kind=class="tok-string">"revolute", axis=class="tok-string">"+Y", range=(-90,90))
return s3d.group(class="tok-string">"bin_housing", parent, broad, narrow, lid)
def broad_inner_flap(w=197, d=340, h=20, t=3, r=20):
frame = s3d.extrude(class="tok-string">"frame", s3d.rect(w=w, d=d, r=r), h=h)
tool = s3d.at(s3d.box(class="tok-string">"opening", w=w, d=d-t*2, h=h+t*2), x=-t, z=-t)
frame = s3d.cut(frame, tool)
s3d.material(frame, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#343a3b")
return s3d.group(class="tok-string">"broad_inner_flap", frame)
def narrow_inner_flap(w=187, d=330, h=20, t=3, r=20):
frame = s3d.extrude(class="tok-string">"frame", s3d.rect(w=w, d=d, r=r), h=h)
tool = s3d.at(s3d.box(class="tok-string">"opening", w=w, d=d-t*2, h=h+t*2), x=t, z=-t)
frame = s3d.cut(frame, tool)
s3d.material(frame, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#343a3b")
return s3d.group(class="tok-string">"narrow_inner_flap", frame)
def swing_lid(w=264, d=258, h=136.3, r=30, t=3, pin_d=18, pin_l=15, pivot_h=106):
profile = s3d.poly([(-w/2,0), (w/2,0), s3d.arc(center=(0,h-r), r=r, start=40, end=140)])
roof = s3d.extrude(class="tok-string">"swing_roof", profile, h=d)
cavity = s3d.poly([(-w/2,-t), (w/2,-t), s3d.arc(center=(0,h-r), r=r-t, start=40, end=140)])
inner = s3d.at(s3d.extrude(class="tok-string">"inside", cavity, h=d-t*2), z=t)
roof = s3d.cut(roof, inner)
roof = s3d.at(roof, y=d/2, rx=90)
pin = s3d.at(s3d.cylinder(class="tok-string">"hinge_pin", d=pin_d, h=pin_l+t), y=d/2-t, z=pivot_h, rx=-90)
pin2 = s3d.at(s3d.copy(pin), y=-d/2+t, rx=90)
roof = s3d.join(roof, pin, pin2)
s3d.material(roof, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#343a3b")
return s3d.group(class="tok-string">"swing_lid", roof)