import sand3d as s3d
def vending_machine():
root=s3d.at(cabinet(),x=34,y=-1,z=4)
return s3d.assembly(&class="tok-comment">#39;vending_machine39;,root)
def cabinet(w=867,d=756,h=1835,t=5,front=404,shelf_w=700,shelf_d=496,shelf_z=548,pitch=201,divider_h=110,column_d=180):
skin=s3d.at(s3d.box(&class="tok-comment">#39;case39;,w=w,d=d,h=h),x=front-w/2,y=t/t,z=t*1.5)
skin=s3d.shell(skin,t=t,open=&class="tok-comment">#39;+X39;)
s3d.material(skin,&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#d2d4d539;)
panel=s3d.at(s3d.box(&class="tok-comment">#39;control_column39;,w=4*t,d=column_d,h=h),x=front-2*t,y=(d-column_d)/2,z=t*1.5)
s3d.material(panel,&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#b9bec139;)
liner=s3d.at(s3d.box(&class="tok-comment">#39;inner_compartment39;,w=shelf_w+5*t,d=shelf_d+5*t,h=h-pitch-2*t),x=t,y=-divider_h+4*t,z=pitch-1.5*t)
liner=s3d.shell(liner,t=t,open=&class="tok-comment">#39;+X39;)
s3d.material(liner,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#a7abad39;)
shelf=s3d.at(s3d.box(&class="tok-comment">#39;tray39;,w=shelf_w,d=shelf_d,h=t),x=3*t,y=-divider_h+2*t,z=shelf_z)
div=s3d.at(s3d.box(&class="tok-comment">#39;divider39;,w=shelf_w,d=t,h=divider_h),on=s3d.grid(nx=1,ny=5,py=81),x=3*t,y=-divider_h+2*t,z=shelf_z)
s3d.material(div,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#95999c39;)
s3d.material(shelf,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#95999c39;)
tray=s3d.group(&class="tok-comment">#39;tray_set39;,shelf,div)
trays=[tray]
for i in range(1,6):
trays.append(s3d.transform(s3d.copy(tray),z=i*pitch))
housings=[]
for z in (1460,1590,1660):
block=s3d.at(s3d.box(&class="tok-comment">#39;payment_housing39;,w=8*t,d=113,h=70),x=front+3*t,y=(d-column_d)/2-3*t,z=z)
s3d.material(block,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#53585c39;)
housings.append(block)
parent=s3d.group(&class="tok-comment">#39;structure39;,skin,panel,liner,trays,housings)
door=s3d.at(display_door(),x=393.5,y=-100.5,z=483)
s3d.joint(&class="tok-comment">#39;joint_door_01_joint_00class="tok-string">39;,door,on=s3d.local(parent,x=393,y=-350,z=1161),kind=39;revoluteclass="tok-string">39;,axis=39;+Z39;,range=(-90,0))
knob=s3d.at(rotary_control(),x=412,y=244,z=1151)
s3d.joint(&class="tok-comment">#39;joint_button_02_joint_00class="tok-string">39;,knob,on=s3d.local(parent,x=423,y=244,z=1163),kind=39;continuousclass="tok-string">39;,axis=39;+X39;)
b1=s3d.at(upper_button(),x=439,y=302.5,z=1682)
s3d.joint(&class="tok-comment">#39;joint_button_01_joint_00class="tok-string">39;,b1,on=s3d.local(parent,x=442,y=303,z=1687),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(-2.5,0))
b4=s3d.at(lower_button(),x=439,y=241.5,z=1682)
s3d.joint(&class="tok-comment">#39;joint_button_04_joint_00class="tok-string">39;,b4,on=s3d.local(parent,x=442,y=241,z=1687),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(-2.5,0))
lid=s3d.at(dispensing_lid(),x=379.5,y=-102,z=191)
s3d.joint(&class="tok-comment">#39;joint_lid_01_joint_00class="tok-string">39;,lid,on=s3d.local(parent,x=403,y=144,z=210),kind=39;revoluteclass="tok-string">39;,axis=39;+Y39;,range=(0,25))
b3=s3d.at(middle_button(),x=439,y=272,z=1682)
s3d.joint(&class="tok-comment">#39;joint_button_03_joint_00class="tok-string">39;,b3,on=s3d.local(parent,x=442,y=272,z=1687),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(-2.5,0))
return s3d.group(&class="tok-comment">#39;cabinet39;,parent,door,knob,b1,b4,lid,b3)
def display_door(w=19,d=539,h=1355):
ob=s3d.box(&class="tok-comment">#39;door39;,w=w,d=d,h=h)
s3d.material(ob,&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#c3c7c939;)
return s3d.group(&class="tok-comment">#39;display_door39;,ob)
def rotary_control(w=22,d=24,h=24):
ob=s3d.at(s3d.cylinder(&class="tok-comment">#39;knob39;,d=d,h=w),x=-w/2,z=h/2,ry=90)
s3d.material(ob,&class="tok-comment">#39;chromeclass="tok-string">39;,color=39;#b6b9bc39;)
return s3d.group(&class="tok-comment">#39;rotary_control39;,ob)
def upper_button(w=4,d=19,h=10):
ob=s3d.box(&class="tok-comment">#39;button39;,w=w,d=d,h=h)
s3d.material(ob,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#42474a39;)
return s3d.group(&class="tok-comment">#39;upper_button39;,ob)
def lower_button(w=4,d=19,h=10):
ob=s3d.box(&class="tok-comment">#39;button39;,w=w,d=d,h=h)
s3d.material(ob,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#42474a39;)
return s3d.group(&class="tok-comment">#39;lower_button39;,ob)
def dispensing_lid(w=169,d=480,h=265,t=4,bottom=22,front=73):
outline=[(-w/2,h*.78),(bottom,0),(front,h*.27),(w/2,h*.88),(w/2-t,h),(w/2-2*t,h*.88),(front-t,h*.27),(bottom,h*.04),(-w/2+t,h*.78)]
ob=s3d.at(s3d.extrude(&class="tok-comment">#39;flap39;,s3d.poly(pts=outline),h=d),y=d/2,rx=90)
cheek=s3d.poly(pts=[(-w/2+t,h*.78),(bottom,t),(front,h*.27),(w/2-t,h*.88)])
side=s3d.at(s3d.extrude(&class="tok-comment">#39;cheek39;,cheek,h=t),y=d/2,rx=90)
twin=s3d.transform(s3d.copy(side),y=-d+t)
ob=s3d.join(ob,side,twin)
s3d.material(ob,&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#979da139;)
return s3d.group(&class="tok-comment">#39;dispensing_lid39;,ob)
def middle_button(w=4,d=18,h=10):
ob=s3d.box(&class="tok-comment">#39;button39;,w=w,d=d,h=h)
s3d.material(ob,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#42474a39;)
return s3d.group(&class="tok-comment">#39;middle_button39;,ob)