import sand3d as s3d
def wheelie_bin():
base = s3d.at(bin_body(), x=0, y=0, z=0)
cover = s3d.at(lid(), x=2, y=0, z=1030)
s3d.joint(&class="tok-comment">#39;joint_sm_lid_a01_joint_00class="tok-string">39;, cover, on=s3d.local(base, x=2, y=409, z=1053), kind=39;revoluteclass="tok-string">39;, axis=39;+X39;, range=(-90,0))
tire = s3d.at(wheel(), x=-265, y=231, z=0)
image = s3d.transform(s3d.copy(tire), mirror=&class="tok-comment">#39;x39;)
s3d.joint(&class="tok-comment">#39;joint_sm_wheel1_a01_joint_00class="tok-string">39;, tire, on=s3d.local(base, x=-265, y=231, z=125), kind=39;continuousclass="tok-string">39;, axis=39;+X39;)
s3d.joint(&class="tok-comment">#39;joint_sm_wheel2_a01_joint_00class="tok-string">39;, image, on=s3d.local(base, x=265, y=231, z=125), kind=39;continuousclass="tok-string">39;, axis=39;+X39;)
return s3d.assembly(&class="tok-comment">#39;wheelie_bin39;, base, cover, tire, image)
def bin_body(w=690,d=680,h=1045,bottom_w=635,bottom_d=640,shoulder=850,rim_w=835,rim_d=815,wall=14,corner=140,radius=100,rear=-30,recess=150,mouth_w=760,mouth_d=710,rim_r=95,rim_h=45,front_half=110,front_tip=65,front_h=650,knee=400,back_h=600,back_knee=430,clearance_h=120):
lower=s3d.at(bin_outline(w=bottom_w,d=bottom_d,c=corner,r=radius),y=rear)
middle=s3d.at(bin_outline(w=w,d=d,c=corner,r=radius),y=rear,z=shoulder-radius*2)
upper=s3d.at(bin_outline(w=(w+mouth_w)/2,d=mouth_d,c=90,r=radius),y=rear,z=shoulder)
lip=s3d.at(bin_outline(w=mouth_w,d=mouth_d,c=90,r=radius),y=rear,z=h)
body=s3d.loft(&class="tok-comment">#39;body39;,lower,middle,upper,lip)
front_tool=s3d.extrude(&class="tok-comment">#39;front recess39;,s3d.poly([(-front_half,-wall),(front_half,-wall),(front_half,knee),(front_tip,front_h),(-front_tip,front_h),(-front_half,knee)]),h=-rear*2)
front_tool=s3d.at(front_tool,y=-292,rx=92.5)
back_tool=s3d.extrude(&class="tok-comment">#39;back recess39;,s3d.poly([(-recess,-wall),(recess,-wall),(radius,back_knee),(-rear*2,back_h),(rear*2,back_h),(-radius,back_knee)]),h=recess-rear)
back_tool=s3d.at(back_tool,y=d/2-rear,rx=78.5)
body=s3d.cut(body,front_tool,back_tool)
clearance=s3d.extrude(&class="tok-comment">#39;wheel clearance39;,s3d.rect(w=recess*2,d=radius*5,r=radius),h=clearance_h)
clearance=s3d.at(clearance,x=205,y=250,z=0,ry=90)
body=s3d.cut(body,clearance,s3d.transform(s3d.copy(clearance),mirror=&class="tok-comment">#39;x39;))
body=s3d.shell(body,t=wall,open=&class="tok-comment">#39;end39;)
rim=s3d.at(s3d.extrude(&class="tok-comment">#39;rim39;,s3d.rect(w=rim_w,d=rim_d,r=rim_r),h=rim_h),y=-20,z=h-rim_h)
rim=s3d.shell(rim,t=wall,open=&class="tok-comment">#39;top bottom39;)
flange=s3d.at(s3d.extrude(&class="tok-comment">#39;mouth flange39;,s3d.rect(w=rim_w,d=rim_d,r=rim_r),h=wall),y=-20,z=h-wall)
flange=s3d.pocket(flange,s3d.rect(w=mouth_w-wall,d=mouth_d-wall,r=radius),on=flange.face(&class="tok-comment">#39;top39;))
apron=s3d.at(s3d.box(&class="tok-comment">#39;front apron39;,w=w,d=wall,h=clearance_h),y=-rim_d/2-20,z=h-clearance_h)
handle=s3d.at(s3d.cylinder(&class="tok-comment">#39;handle39;,d=40,h=mouth_w),x=-mouth_w/2,y=409,z=1053,ry=90)
support=s3d.at(s3d.box(&class="tok-comment">#39;handle support39;,w=rim_h,d=corner-wall*2,h=radius/2),on=s3d.grid(nx=2,px=rim_w-rim_r),y=mouth_d/2,z=h-rim_h)
result=s3d.group(&class="tok-comment">#39;bin_body39;,body,rim,flange,apron,handle,support)
s3d.material(result,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#354b3939;,roughness=0.7)
return result
def bin_outline(w,d,c,r):
return s3d.poly([(-w/2,d/2),(w/2,d/2),(w/2,-d/2+c),(w/2-c,-d/2),(-w/2+c,-d/2),(-w/2,-d/2+c)],fillet=r)
def lid(w=815,d=760,t=14,panel_w=650,panel_d=525,rise=107,slope=-8,flange=30):
plate=s3d.at(s3d.extrude(&class="tok-comment">#39;lid lip39;,s3d.rect(w=w,d=d,r=85),h=t),y=-50,z=flange)
plate=s3d.pocket(plate,s3d.rect(w=750,d=570,r=60),on=plate.face(&class="tok-comment">#39;top39;).move(y=-40))
low=s3d.at(s3d.rect(w=795,d=590,r=65),y=-90,z=flange+t/2)
middle=s3d.at(s3d.rect(w=795,d=590,r=65),y=-90,z=70,rx=-5)
high=s3d.at(s3d.rect(w=panel_w,d=panel_d,r=45),y=-90,z=rise,rx=slope)
panel=s3d.loft(&class="tok-comment">#39;raised lid39;,low,middle,high)
panel=s3d.shell(panel,t=8,open=&class="tok-comment">#39;start39;)
hinges=s3d.at(s3d.cylinder(&class="tok-comment">#39;hinge39;,d=50,h=70),on=s3d.grid(nx=2,px=620),y=409,z=23,ry=90)
arms=s3d.at(s3d.box(&class="tok-comment">#39;hinge arms39;,w=40,d=95,h=t),on=s3d.grid(nx=2,px=620),y=365,z=flange)
result=s3d.group(&class="tok-comment">#39;lid39;,plate,panel,hinges,arms)
s3d.material(result,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#354b3939;,roughness=0.65)
return result
def wheel(w=80,d=250,hub=100,full_w=107):
tire=s3d.cylinder(&class="tok-comment">#39;tire39;,d=d,h=w)
tire=s3d.fillet(tire,r=15)
tire=s3d.at(tire,x=-w/2-5,z=d/2,ry=90)
cap=s3d.at(s3d.cylinder(&class="tok-comment">#39;hub39;,d=hub,h=full_w),x=-full_w/2,z=d/2,ry=90)
s3d.material(tire,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#25252539;)
s3d.material(cap,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#53595339;)
return s3d.group(&class="tok-comment">#39;wheel39;,tire,cap)