import sand3d as s3d
def wheelie_bin():
body = s3d.at(bin_body(), z=1)
wh = s3d.at(wheel(), x=173.5, y=137)
twin = s3d.transform(s3d.copy(wh), mirror=class="tok-string">"x")
cover = s3d.at(lid(), y=20.5, z=842)
s3d.joint(class="tok-string">"joint_sm_wheel1_a01_joint_00", wh, s3d.local(body, x=190, y=137, z=101), axis=class="tok-string">"+X", range=(-62831.9, 62831.9))
s3d.joint(class="tok-string">"joint_sm_wheel2_a01_joint_00", twin, s3d.local(body, x=-174, y=137, z=101), axis=class="tok-string">"+X", range=(-62831.9, 62831.9))
s3d.joint(class="tok-string">"joint_sm_lid_a01_joint_00", cover, s3d.local(body, x=0, y=343, z=858), axis=class="tok-string">"+X", range=(-110, 0))
return s3d.assembly(class="tok-string">"wheelie_bin", body, wh, twin, cover)
def bin_body(w=500, d=544, h=840, base_w=431, base_d=470, base_y=-3, top_y=-25, collar_z=580, recess_w=180, recess_d=34, relief_h=200, wall=5, lip_w=582, lip_d=670, n=8, clearance=20, floor=0, axle_y=137, axle_z=100, well_d=230):
main = s3d.loft(class="tok-string">"tapered_body", s3d.station(z=floor, w=base_w, d=base_d, y=base_y, n=n), s3d.station(z=collar_z, w=w, d=d, y=top_y, n=n))
recess = s3d.loft(class="tok-string">"front_recess", s3d.station(z=-1, w=recess_w, d=recess_d*2, y=-base_d/2, n=clearance), s3d.station(z=collar_z+1, w=recess_w, d=recess_d*2, y=-d/2-14, n=clearance))
s3d.cut(main, recess)
relief = s3d.extrude(class="tok-string">"wheel_clearance", s3d.poly([(floor,floor),(w/2,floor),(w/2,relief_h),(recess_w,relief_h),s3d.spline([(recess_w,relief_h*2/3),(relief_h/2,relief_h/2),(wall,wall*n)])]), h=w+clearance, both=True)
relief = s3d.at(relief, rx=90, rz=90)
s3d.cut(main, relief)
well = s3d.at(s3d.cylinder(class="tok-string">"wheel_well", d=well_d, h=relief_h), x=recess_w-clearance, y=axle_y, z=axle_z, ry=90)
other = s3d.transform(s3d.copy(well), mirror=class="tok-string">"x")
s3d.cut(main, well, other)
strip = s3d.loft(class="tok-string">"side_recess", s3d.station(z=floor, w=wall*n*2, d=relief_h*2, x=base_w/2+wall*n-clearance/2, y=relief_h, n=clearance), s3d.station(z=collar_z/2, w=wall*n*2, d=relief_h*2, x=(base_w+w)/4+wall*n-clearance/2, y=relief_h, n=clearance), s3d.station(z=collar_z, w=wall*n*2, d=relief_h*2, x=w/2+wall*n-clearance/2, y=relief_h*2, n=clearance))
twin = s3d.transform(s3d.copy(strip), mirror=class="tok-string">"x")
s3d.cut(main, strip, twin)
collar = s3d.loft(class="tok-string">"upper_collar", s3d.station(z=collar_z-2, w=w+14, d=d+22, y=top_y, n=n), s3d.station(z=h, w=w+recess_d, d=d+recess_d+clearance/2, y=top_y, n=n))
s3d.join(main, collar)
s3d.shell(main, t=wall, open=class="tok-string">"+Z")
lip = s3d.extrude(class="tok-string">"rolled_lip", s3d.rect(w=lip_w, d=lip_d, r=wall*n*2), h=wall*3)
s3d.pocket(lip, s3d.rect(w=w+clearance, d=d+wall*6, r=wall*12), on=lip.face(class="tok-string">"top"))
lip = s3d.at(lip, y=top_y, z=h-wall)
s3d.join(main, lip)
bar = s3d.at(s3d.cylinder(class="tok-string">"handle", d=wall*6, h=w), x=-w/2, y=343, z=858, ry=90)
support = s3d.box(class="tok-string">"handle_support", w=wall*6, d=wall*n*2, h=wall*6)
supports = s3d.at(support, on=s3d.grid(nx=3, px=w/2-wall*2), y=d/2+wall*6, z=h)
grip = s3d.at(s3d.box(class="tok-string">"front_grip", w=recess_w*1.5, d=wall*n, h=wall*3), y=-lip_d/2, z=h-wall*n)
bridge = s3d.at(s3d.box(class="tok-string">"front_bridge", w=recess_w+wall*2, d=recess_d, h=wall*wall), y=-d/2, z=h/2-wall)
s3d.join(main, bridge)
axle = s3d.at(s3d.cylinder(class="tok-string">"axle", d=wall*3, h=base_w), x=-base_w/2, y=axle_y, z=axle_z, ry=90)
s3d.material(axle, kind=class="tok-string">"steel", color=class="tok-string">"class="tok-comment">#696e6b")
s3d.material(main, kind=class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#34483d")
s3d.material(bar, kind=class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#34483d")
s3d.material(supports, kind=class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#34483d")
s3d.material(grip, kind=class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#34483d")
return s3d.group(class="tok-string">"bin_body", main, bar, supports, grip, axle)
def wheel(d=202, t=37, hub_d=56, rim=14, offset=16.5):
tyre = s3d.tube(class="tok-string">"tyre", d=d, d_in=d-rim*2, h=t)
disk = s3d.at(s3d.cylinder(class="tok-string">"wheel_web", d=d-rim, h=8), z=t/2-4)
hub = s3d.at(s3d.cylinder(class="tok-string">"hub", d=hub_d, h=t+12), z=-6)
spoke = s3d.at(s3d.box(class="tok-string">"spoke", w=14, d=d/2-hub_d/2, h=t-8), y=(d+hub_d)/4, z=4)
spokes = s3d.at(spoke, on=s3d.ring(n=6, r=0))
s3d.join(tyre, disk, hub, spokes)
tyre = s3d.at(tyre, x=offset-t/2, z=d/2, ry=90)
s3d.material(tyre, kind=class="tok-string">"rubber", color=class="tok-string">"class="tok-comment">#252826")
return s3d.group(class="tok-string">"wheel", tyre)
def lid(w=591, d=670, h=90, rim_h=30, r=72, panel_w=460, panel_d=550, slope=34, wall=3, rim_y=-23.5):
rim = s3d.at(s3d.extrude(class="tok-string">"lid_rim", s3d.rect(w=w, d=d, r=r), h=rim_h), y=rim_y)
crown = s3d.body(class="tok-string">"raised_lid", plan=[(-panel_d/2, panel_w-70), (-panel_d/2+45, panel_w), (panel_d/2-45, panel_w), (panel_d/2, panel_w-70)], top=[(-panel_d/2, rim_h+wall), (-panel_d/2+35, h-12), (-130, h-12), (panel_d/2-20, h-12-slope), (panel_d/2, rim_h+wall)], bottom=rim_h-wall*2, n=8)
crown = s3d.at(crown, y=-35)
s3d.join(rim, crown)
s3d.shell(rim, t=wall, open=class="tok-string">"bottom")
lug = s3d.at(s3d.extrude(class="tok-string">"hinge_lug", s3d.rect(w=35, d=110, r=12), h=26), x=w/2-30, y=d/2-30)
image = s3d.transform(s3d.copy(lug), mirror=class="tok-string">"x")
s3d.join(rim, lug, image)
s3d.material(rim, kind=class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#34483d")
return s3d.group(class="tok-string">"lid", rim)