import sand3d as s3d
def kettle():
root = s3d.at(body(), y=18.5)
return s3d.assembly(&class="tok-comment">#39;kettle39;, root)
def body(r=104,h=235,cy=-23.5,wall=3,handle_w=25,spout_w=52,base=20,belly=80,shoulder=145,neck=200,mouth=57,reach=147,handle_top=232,heel=94,handle_bottom=52,crown=106,handle_mid=152):
outer=[(r,0),(r-wall,base),(r-wall*2,belly),(r-wall*6,shoulder),(r-wall*10,neck),(mouth,h)]
inner=[(mouth-wall,h),(r-wall*11,neck),(r-wall*7,shoulder),(r-wall*3,belly),(r-wall*5,base/2)]
vessel=s3d.revolve(&class="tok-comment">#39;vessel39;,s3d.poly([(0,0),(r,0),s3d.spline(outer),inner[0],s3d.spline(inner),(0,base/2)]))
vessel=s3d.at(vessel,y=cy)
outer_handle=s3d.poly([(mouth+wall*4,handle_top),s3d.spline([(mouth+wall*4,handle_top),(crown,handle_top-wall),(reach-wall*3,neck+wall),(reach,handle_mid),(reach-base,belly-wall),(heel,handle_bottom)]),(mouth+base,neck+base),(mouth+wall*4,handle_top)])
handle=s3d.extrude(&class="tok-comment">#39;handle39;,outer_handle,h=handle_w,both=True)
opening=s3d.poly([(heel+wall,belly+wall*3),s3d.spline([(heel+wall,belly+wall*3),(r,belly+wall),(reach-handle_w,belly+base*2),(reach-handle_w,handle_mid+base/2),(r,neck-wall),(mouth+base,neck+base/2),(mouth+base-wall,neck),(heel-wall*2,handle_mid),(heel+wall,belly+wall*3)])])
handle=s3d.cut(handle,s3d.extrude(&class="tok-comment">#39;opening39;,opening,h=handle_w*2,both=True))
handle=s3d.at(handle,rx=90,rz=90,y=cy+5)
spout=s3d.loft(&class="tok-comment">#39;spout39;,s3d.station(z=shoulder-wall,w=wall*4,d=wall*3,y=-heel),s3d.station(z=neck-base,w=spout_w-wall*6,d=handle_w,y=-heel),s3d.station(z=h-handle_w/2,w=spout_w,d=handle_w+wall*4,y=-heel+wall))
spout=s3d.shell(spout,t=wall,open=&class="tok-comment">#39;end39;)
spout=s3d.at(spout,y=cy+5)
s3d.material(vessel,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#dedbd439;)
s3d.material(handle,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#393b3d39;)
s3d.material(spout,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#dedbd439;)
top = s3d.at(lid(),x=-0.5,y=-22.5,z=228)
tab = s3d.at(switch(),x=-0.5,y=91,z=25)
key = s3d.at(button(),x=-0.5,y=50,z=226)
root = s3d.group(&class="tok-comment">#39;body39;,vessel,handle,spout,top,tab,key)
s3d.joint(&class="tok-comment">#39;joint_sm_kitchenware_kettle_j01_lid_joint_00class="tok-string">39;,top,s3d.local(root,x=0,y=34,z=235),kind=39;revoluteclass="tok-string">39;,axis=39;+X39;,range=(-75,0))
s3d.joint(&class="tok-comment">#39;joint_sm_kitchenware_kettle_j01_switch_joint_00class="tok-string">39;,tab,s3d.local(root,x=-1,y=68.5,z=30),kind=39;revoluteclass="tok-string">39;,axis=39;+X39;,range=(0,10))
s3d.joint(&class="tok-comment">#39;joint_sm_kitchenware_kettle_j01_button_joint_00class="tok-string">39;,key,s3d.local(root,x=0,y=49.5,z=234),kind=39;revoluteclass="tok-string">39;,axis=39;+X39;,range=(-22,0))
return root
def lid(w=113,d=114,h=21,plug=70,lip=6,flat=27):
cap=s3d.revolve(&class="tok-comment">#39;lid39;,s3d.poly([(0,0),(plug/2,0),(plug/2,lip),(w/2,lip),s3d.spline([(w/2,lip),(w/2-lip,lip*2),(plug/2,h),(flat,h)]),(0,h)]))
s3d.material(cap,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#393b3d39;)
return s3d.group(&class="tok-comment">#39;lid39;,cap)
def switch(w=25,d=45,h=6):
tab=s3d.box(&class="tok-comment">#39;switch39;,w=w,d=d,h=h)
s3d.fillet(tab,r=h/4)
s3d.material(tab,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#393b3d39;)
return s3d.group(&class="tok-comment">#39;switch39;,tab)
def button(w=11,d=19,h=13):
key=s3d.box(&class="tok-comment">#39;button39;,w=w,d=d,h=h)
s3d.material(key,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#393b3d39;)
return s3d.group(&class="tok-comment">#39;button39;,key)