import sand3d as s3d
def kettle():
body = s3d.at(kettle_body(), y=25.5)
switch = s3d.at(power_switch(), y=78, z=25)
button = s3d.at(handle_button(), y=98, z=226)
cover = s3d.at(lid(), y=-7.5, z=236)
s3d.joint(&class="tok-comment">#39;joint_sm_kitchenware_kettle_n01_switch_joint_00class="tok-string">39;, switch, on=s3d.local(body, 0, 37.5, 30), kind=39;revoluteclass="tok-string">39;, axis=39;+X39;, range=(-10, 0))
s3d.joint(&class="tok-comment">#39;joint_sm_kitchenware_kettle_n01_button_joint_00class="tok-string">39;, button, on=s3d.local(body, 0, 72.5, 236), kind=39;prismaticclass="tok-string">39;, axis=39;+Z39;, range=(-2, 0))
s3d.joint(&class="tok-comment">#39;joint_sm_kitchenware_kettle_n01_lid_joint_00class="tok-string">39;, cover, on=s3d.local(body, 0, 17.5, 239), kind=39;revoluteclass="tok-string">39;, axis=39;+X39;, range=(-70, 0))
return s3d.assembly(&class="tok-comment">#39;kettle39;, body, switch, button, cover)
def kettle_body(base_d=160.9, foot_h=12, collar_d=151, floor_h=50, belly_d=157, shoulder_d=149, neck_d=122, top_h=237, wall=3, cy=-33, handle_w=30, hlow=65, hhigh=225, reach=128, spout_w=28):
foot = s3d.at(s3d.cone(&class="tok-comment">#39;foot39;, d=base_d, d2=collar_d, h=foot_h), y=cy)
collar = s3d.at(s3d.cylinder(&class="tok-comment">#39;collar39;, d=collar_d, h=floor_h-foot_h), y=cy, z=foot_h-wall)
vessel = s3d.loft(&class="tok-comment">#39;vessel39;, s3d.station(z=floor_h-wall*2, w=base_d-wall, d=base_d-wall), s3d.station(z=95, w=belly_d, d=belly_d), s3d.station(z=147, w=shoulder_d, d=shoulder_d), s3d.station(z=199, w=133, d=133), s3d.station(z=top_h, w=neck_d, d=neck_d))
vessel = s3d.shell(vessel, t=wall, open=&class="tok-comment">#39;end39;)
vessel = s3d.at(vessel, y=cy)
rim = s3d.revolve(&class="tok-comment">#39;top_rim39;, s3d.poly([(neck_d/2, top_h-wall), (neck_d/2, top_h), (neck_d/2-wall, top_h+wall), (neck_d/2-wall*3, top_h+wall), (neck_d/2-wall*3, top_h), (neck_d/2-wall, top_h-wall)]))
rim = s3d.at(rim, y=cy)
path = s3d.spline([(0, 66-25.5, hlow), (0, 105-25.5, 105), (0, reach-25.5, 158), (0, 120-25.5, 202), (0, 88-25.5, hhigh), (0, 58-25.5, hhigh)])
handle = s3d.wire(&class="tok-comment">#39;handle39;, path=path, d=handle_w)
lip_y = cy-neck_d/2
spout = s3d.loft(&class="tok-comment">#39;pouring_lip39;, s3d.station(z=185, w=wall*3, d=wall*3, y=lip_y), s3d.station(z=hhigh, w=spout_w, d=22, y=lip_y-wall*3))
hollow = s3d.loft(&class="tok-comment">#39;lip_opening39;, s3d.station(z=185+wall, w=wall, d=wall, y=lip_y), s3d.station(z=hhigh+wall, w=spout_w-wall, d=22-wall, y=lip_y-wall*3))
spout = s3d.cut(spout, hollow)
for ob in (foot, collar, vessel, rim, handle, spout):
s3d.material(ob, kind=&class="tok-comment">#39;plasticclass="tok-string">39;, color=39;#d9dce039;)
return s3d.group(&class="tok-comment">#39;kettle_body39;, foot, collar, vessel, rim, handle, spout)
def power_switch(w=24, d=32, h=6):
paddle = s3d.extrude(&class="tok-comment">#39;switch39;, s3d.rect(w=w, d=d, r=w/3), h=h)
s3d.fillet(paddle, r=h/3)
s3d.material(paddle, kind=&class="tok-comment">#39;plasticclass="tok-string">39;, color=39;#363b4239;)
return s3d.group(&class="tok-comment">#39;power_switch39;, paddle)
def handle_button(w=14, d=28, h=3, slope=-25):
button = s3d.extrude(&class="tok-comment">#39;button39;, s3d.rect(w=w, d=d, r=w/2), h=h)
button = s3d.at(button, z=d/4, rx=slope)
s3d.material(button, kind=&class="tok-comment">#39;plasticclass="tok-string">39;, color=39;#363b4239;)
return s3d.group(&class="tok-comment">#39;handle_button39;, button)
def lid(d=104, h=15, t=2):
cover = s3d.revolve(&class="tok-comment">#39;lid39;, s3d.poly([(0, h), s3d.spline([(0, h), (d/4, h*0.8), (d/2, t)]), (d/2, 0), s3d.spline([(d/2, 0), (d/4, h*0.8-t), (0, h-t)])]))
s3d.material(cover, kind=&class="tok-comment">#39;plasticclass="tok-string">39;, color=39;#d9dce039;)
return s3d.group(&class="tok-comment">#39;lid39;, cover)