import sand3d as s3d
def refuse_bin():
body=s3d.at(bin_body(),z=24)
wheel=s3d.at(rear_wheel(),x=-247.5,y=70)
twin=s3d.transform(s3d.copy(wheel),mirror=class="tok-string">"x")
s3d.joint(class="tok-string">"joint_sm_rear_wheel2_a01_joint_00",wheel,s3d.local(body,x=-279,y=70,z=99),kind=class="tok-string">"continuous",axis=class="tok-string">"+X")
s3d.joint(class="tok-string">"joint_sm_rear_wheel1_a01_joint_00",twin,s3d.local(body,x=243,y=70,z=99),kind=class="tok-string">"continuous",axis=class="tok-string">"+X")
frame=s3d.at(caster_frame(),x=-186,y=-357,z=43)
image=s3d.at(caster_frame(wheel_joint=class="tok-string">"joint_sm_wheel1_a01_joint_00"),x=186,y=-357,z=43)
s3d.joint(class="tok-string">"joint_sm_frame1_a01_joint_00",frame,s3d.local(body,x=-186,y=-348,z=111),kind=class="tok-string">"continuous",axis=class="tok-string">"+Z")
s3d.joint(class="tok-string">"joint_sm_frame2_a01_joint_00",image,s3d.local(body,x=186,y=-348,z=111),kind=class="tok-string">"continuous",axis=class="tok-string">"+Z")
positive=s3d.at(lid_positive(),y=365,z=899)
negative=s3d.at(lid_negative(),y=-352.5,z=902)
s3d.joint(class="tok-string">"joint_sm_lid1_a01_joint_00",positive,s3d.local(body,x=0,y=22,z=1074),axis=class="tok-string">"+X",range=(0,95))
s3d.joint(class="tok-string">"joint_sm_lid2_a01_joint_00",negative,s3d.local(body,x=0,y=8,z=1074),axis=class="tok-string">"+X",range=(-95,0))
return s3d.assembly(class="tok-string">"refuse_bin",body,wheel,twin,frame,image,positive,negative)
def bin_body(w=674,d=1340,h=956,wall=6,radius=42,loop_w=430,loop_y=337,tube=25,upper_w=620,upper_d=1235,upper_y=-31,upper_z=720,lip=22,band_h=71,lower_w=544,lower_d=730,lower_y=-203,lower_z=190):
outer=s3d.loft(class="tok-string">"bin",s3d.at(s3d.rect(w=470,d=450,r=radius),y=-205,z=radius+band_h),s3d.at(s3d.rect(w=lower_w-wall*2,d=lower_d-band_h,r=radius),y=lower_y-wall*3,z=lower_z-radius),s3d.at(s3d.rect(w=lower_w,d=lower_d,r=radius),y=lower_y,z=lower_z),s3d.at(s3d.rect(w=550,d=1010,r=radius),y=-92,z=376),s3d.at(s3d.rect(w=600,d=1132,r=radius),y=-61,z=494),s3d.at(s3d.rect(w=upper_w,d=upper_d,r=radius),y=upper_y,z=upper_z),s3d.at(s3d.rect(w=upper_w+lip*2,d=upper_d+lip,r=radius),y=upper_y+lip/2,z=upper_z+band_h),s3d.at(s3d.rect(w=w,d=d,r=radius),z=h))
outer=s3d.shell(outer,t=wall,open=class="tok-string">"end")
s3d.material(outer,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#3e5145")
rim=s3d.at(s3d.extrude(class="tok-string">"rim",s3d.rect(w=w+wall*8,d=d+wall*8,r=radius),h=wall*3),z=h-wall*3)
rim=s3d.shell(rim,t=wall,open=class="tok-string">"top bottom")
s3d.material(rim,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#3e5145")
loop=s3d.wire(class="tok-string">"pedal_loop",path=[(-loop_w/2,band_h,99),(-loop_w/2,loop_y,wall*3),(loop_w/2,loop_y,wall*3),(loop_w/2,band_h,99)],d=tube)
s3d.material(loop,class="tok-string">"steel",color=class="tok-string">"class="tok-comment">#777b78")
return s3d.group(class="tok-string">"bin_body",outer,rim,loop)
def rear_wheel(w=75,d=245,hub=135,inset=8):
tire=s3d.at(s3d.cylinder(class="tok-string">"tire",d=d,h=w),x=-w/2,z=d/2,ry=90)
tire=s3d.hole(tire,d=hub,on=tire.face(class="tok-string">"top"),depth=inset)
tire=s3d.hole(tire,d=hub,on=tire.face(class="tok-string">"bottom"),depth=inset)
s3d.material(tire,class="tok-string">"rubber",color=class="tok-string">"class="tok-comment">#252827")
center=s3d.at(s3d.cylinder(class="tok-string">"hub",d=hub-inset,h=w-inset),x=-(w-inset)/2,z=d/2,ry=90)
s3d.material(center,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#666c68")
return s3d.group(class="tok-string">"rear_wheel",tire,center)
def caster_frame(w=52,d=70,h=91,t=7,wheel_joint=class="tok-string">"joint_sm_wheel2_a01_joint_00"):
cap=s3d.at(s3d.cylinder(class="tok-string">"swivel",d=w,h=t*2),y=9,z=h-t*2)
cheek=s3d.extrude(class="tok-string">"fork",s3d.poly([(-d/2,0),(-d/4,0),(d/2,h-t*2),(-d/2,h-t*2)]),h=t)
cheek=s3d.at(cheek,x=-w/2,rx=90,rz=90)
twin=s3d.transform(s3d.copy(cheek),mirror=class="tok-string">"x")
solid=s3d.join(cap,cheek,twin)
s3d.material(solid,class="tok-string">"steel",color=class="tok-string">"class="tok-comment">#747b75")
wheel=s3d.at(caster_wheel(),y=-17.5,z=-43)
frame=s3d.group(class="tok-string">"caster_frame",solid,wheel)
s3d.joint(wheel_joint,wheel,s3d.local(frame,x=0,y=-18,z=8),kind=class="tok-string">"continuous",axis=class="tok-string">"+X")
return frame
def caster_wheel(w=32,d=102,hub=48):
tire=s3d.at(s3d.cylinder(class="tok-string">"caster_tire",d=d,h=w),x=-w/2,z=d/2,ry=90)
tire=s3d.hole(tire,d=hub,on=tire.face(class="tok-string">"top"),depth=w/4)
s3d.material(tire,class="tok-string">"rubber",color=class="tok-string">"class="tok-comment">#252827")
center=s3d.at(s3d.cylinder(class="tok-string">"caster_hub",d=hub,h=w/2),x=-w/4,z=d/2,ry=90)
s3d.material(center,class="tok-string">"steel",color=class="tok-string">"class="tok-comment">#7a807a")
return s3d.group(class="tok-string">"caster_wheel",tire,center)
def lid_positive(w=733,d=692,h=183,t=7,edge=70,top_w=580,top_d=612,rib_w=60,pitch=124,rib_h=28,slope=-2.5):
shell=lid_shell(w=w,d=d,h=h,t=t,edge=edge,top_w=top_w,top_d=top_d,rib_w=rib_w,pitch=pitch,rib_h=rib_h,slope=slope)
return s3d.group(class="tok-string">"lid_positive",shell)
def lid_shell(w,d,h,t,edge,top_w,top_d,rib_w,pitch,rib_h,slope):
sign=1 if slope<0 else -1
shift=sign*(d-top_d)/2
z=h-rib_h
upper=[(-top_w/2,z)]
lower=[(-top_w/2,z-t)]
for i in range(5):
c=(i-2)*pitch
upper.extend([(c-rib_w/2,z),(c-rib_w/2,z+rib_h),(c+rib_w/2,z+rib_h),(c+rib_w/2,z)])
lower.extend([(c-rib_w/2+t,z-t),(c-rib_w/2+t,z+rib_h-t),(c+rib_w/2-t,z+rib_h-t),(c+rib_w/2-t,z-t)])
upper.append((top_w/2,z))
lower.append((top_w/2,z-t))
roof=s3d.extrude(class="tok-string">"corrugated_roof",s3d.poly(upper+list(reversed(lower))),h=top_d-rib_h-t*2)
roof=s3d.at(roof,y=top_d/2-shift-rib_h,rx=90)
cap_profile=s3d.poly(upper+[(top_w/2,z-t),(-top_w/2,z-t)])
endcap=s3d.at(s3d.extrude(class="tok-string">"rib_end",cap_profile,h=t),y=top_d/2-shift-rib_h,rx=90)
startcap=s3d.at(s3d.extrude(class="tok-string">"rib_start",cap_profile,h=t),y=-top_d/2-shift+t*3,rx=90)
skirt=s3d.loft(class="tok-string">"lid_skirt",s3d.at(s3d.rect(w=top_w+t*8,d=d-t*2,r=t*2),z=edge+t),s3d.at(s3d.rect(w=top_w+t,d=top_d+t*2,r=t*2),y=-shift,z=z-rib_h),s3d.at(s3d.rect(w=top_w,d=top_d,r=t*2),y=-shift,z=z))
skirt=s3d.shell(skirt,t=t,open=class="tok-string">"start end")
endfloor=s3d.at(s3d.box(class="tok-string">"rib_end_floor",w=top_w,d=rib_h+t,h=t),y=top_d/2-shift-rib_h/2,z=z-t)
startfloor=s3d.at(s3d.box(class="tok-string">"rib_start_floor",w=top_w,d=t*3,h=t),y=-top_d/2-shift+t,z=z-t)
flange=s3d.loft(class="tok-string">"flange",s3d.at(s3d.rect(w=w,d=d,r=t*2),z=27),s3d.at(s3d.rect(w=w-t*2,d=d-t*2,r=t*2),z=edge+t))
flange=s3d.shell(flange,t=t,open=class="tok-string">"start")
flange=s3d.pocket(flange,s3d.rect(w=top_w+t*6,d=d-t*4,r=t*2),depth=t*3,on=flange.face(class="tok-string">"end"))
strip=s3d.at(s3d.box(class="tok-string">"hinge_strip",w=w-t*8,d=t*3,h=t),y=-sign*(d/2-t*2),z=h-t*2)
tab=s3d.loft(class="tok-string">"hinge_tab",s3d.at(s3d.rect(w=t*4,d=t*10),x=w/2-t*5,y=-sign*(d/2-t*9),z=edge),s3d.at(s3d.rect(w=t*4,d=t*3),x=w/2-t*8,y=-sign*(d/2-t*7),z=h-t*2))
tab_image=s3d.transform(s3d.copy(tab),mirror=class="tok-string">"x")
shell=s3d.join(skirt,roof,flange,strip,tab,tab_image,endcap,startcap,endfloor,startfloor)
notch=s3d.at(s3d.box(class="tok-string">"end_notch",w=rib_w+t*4,d=t*8,h=h),y=sign*(d/2-t*6),z=edge+t)
shell=s3d.cut(shell,notch)
shell=s3d.at(shell,rx=slope)
s3d.material(shell,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#3e5145")
return shell
def lid_negative(w=733,d=743,h=180,t=7,edge=70,top_w=580,top_d=663,rib_w=60,pitch=124,rib_h=28,slope=2.5):
shell=lid_shell(w=w,d=d,h=h,t=t,edge=edge,top_w=top_w,top_d=top_d,rib_w=rib_w,pitch=pitch,rib_h=rib_h,slope=slope)
return s3d.group(class="tok-string">"lid_negative",shell)