import sand3d as s3d
def tool_cabinet():
root = s3d.at(cabinet(), x=-130, y=86.5, z=102)
return s3d.assembly(&class="tok-comment">#39;tool_cabinet39;, root)
def cabinet(w=550, d=800, h=763, t=7, body_z=160, body_h=565, tray_w=582, tray_d=807, tray_t=8, rim_h=24, shelf_d=425, leg_w=24):
cy = -194.5
back = s3d.at(s3d.box(&class="tok-comment">#39;back39;, w=t, d=d, h=body_h), x=-w/2+t/2, y=cy, z=body_z)
ends = s3d.at(s3d.box(&class="tok-comment">#39;end39;, w=w, d=t, h=body_h), on=s3d.grid(nx=1, ny=2, py=d-t), y=cy, z=body_z)
floor = s3d.at(s3d.box(&class="tok-comment">#39;floor39;, w=w, d=d, h=t), y=cy, z=body_z)
divider = s3d.at(s3d.box(&class="tok-comment">#39;divider39;, w=w, d=t, h=body_h), y=cy, z=body_z)
legs = s3d.at(s3d.box(&class="tok-comment">#39;leg39;, w=leg_w, d=leg_w, h=body_z+leg_w), on=s3d.grid(nx=2, ny=2, px=520, py=770), y=cy)
tray = s3d.at(s3d.box(&class="tok-comment">#39;tray39;, w=tray_w, d=tray_d, h=tray_t), y=cy, z=h-rim_h-tray_t)
rim = s3d.extrude(&class="tok-comment">#39;rim39;, s3d.rect(w=tray_w, d=tray_d), h=rim_h)
s3d.pocket(rim, s3d.rect(w=tray_w-2*tray_t, d=tray_d-2*tray_t), depth=rim_h, on=rim.face(&class="tok-comment">#39;top39;))
rim = s3d.at(rim, y=cy, z=h-rim_h)
shelf = s3d.at(s3d.box(&class="tok-comment">#39;shelf39;, w=w, d=shelf_d, h=2*tray_t), y=cy+d/2+shelf_d/2, z=h-rim_h-2*tray_t)
solids = [back, ends, floor, divider, legs, tray, rim, shelf]
for ob in solids:
s3d.material(ob, &class="tok-comment">#39;brushed_steelclass="tok-string">39;, color=39;#a5a8aa39;)
a=s3d.at(deep_drawer(), x=20.5, y=-390, z=185)
b=s3d.at(middle_drawer(), x=20.5, y=-390, z=386)
c=s3d.at(broad_upper_drawer(), x=20.5, y=1, z=498)
e=s3d.at(broad_lower_drawer(), x=19.5, y=1, z=185)
f=s3d.at(top_drawer(), x=20.5, y=-390, z=609)
g=s3d.at(intermediate_drawer(), x=20.5, y=-390, z=497)
parent=s3d.group(&class="tok-comment">#39;cabinet39;, *solids)
s3d.joint(&class="tok-comment">#39;joint_drawer_04_joint_00class="tok-string">39;, a, s3d.local(parent, x=46, y=-390, z=328), kind=39;prismaticclass="tok-string">39;, axis=39;+X39;, range=(0,439.6))
s3d.joint(&class="tok-comment">#39;joint_drawer_03_joint_00class="tok-string">39;, b, s3d.local(parent, x=46, y=-390, z=444), kind=39;prismaticclass="tok-string">39;, axis=39;+X39;, range=(0,439.6))
s3d.joint(&class="tok-comment">#39;joint_drawer_05_joint_00class="tok-string">39;, c, s3d.local(parent, x=52, y=1, z=611), kind=39;prismaticclass="tok-string">39;, axis=39;+X39;, range=(0,433.8))
s3d.joint(&class="tok-comment">#39;joint_drawer_06_joint_00class="tok-string">39;, e, s3d.local(parent, x=36, y=1, z=347), kind=39;prismaticclass="tok-string">39;, axis=39;+X39;, range=(0,449.6))
s3d.joint(&class="tok-comment">#39;joint_drawer_01_joint_00class="tok-string">39;, f, s3d.local(parent, x=46, y=-390, z=667), kind=39;prismaticclass="tok-string">39;, axis=39;+X39;, range=(0,439.6))
s3d.joint(&class="tok-comment">#39;joint_drawer_02_joint_00class="tok-string">39;, g, s3d.local(parent, x=46, y=-390, z=556), kind=39;prismaticclass="tok-string">39;, axis=39;+X39;, range=(0,439.5))
wheel_a=s3d.at(end_caster(), x=259, y=-624, z=-81)
wheel_b=s3d.at(end_caster(joint_name=&class="tok-comment">#39;joint_tire_02_joint_0039;), x=259, y=-624, z=-81)
wheel_b=s3d.transform(wheel_b, mirror=&class="tok-comment">#39;x39;, x=-2)
wheel_c=s3d.at(shelf_caster(), x=259, y=146, z=-81)
wheel_d=s3d.at(shelf_caster(joint_name=&class="tok-comment">#39;joint_tire_04_joint_0039;), x=259, y=146, z=-81)
wheel_d=s3d.transform(wheel_d, mirror=&class="tok-comment">#39;x39;, x=-2)
s3d.joint(&class="tok-comment">#39;joint_wheel_01_joint_00class="tok-string">39;, wheel_a, s3d.local(parent, x=259, y=-578.5, z=8), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_wheel_02_joint_00class="tok-string">39;, wheel_b, s3d.local(parent, x=-261, y=-578.5, z=8), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_wheel_03_joint_00class="tok-string">39;, wheel_c, s3d.local(parent, x=259, y=191.5, z=8), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_wheel_04_joint_00class="tok-string">39;, wheel_d, s3d.local(parent, x=-261, y=191.5, z=8), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
return s3d.group(&class="tok-comment">#39;cabinet_complete39;, parent, a,b,c,e,f,g,wheel_a,wheel_b,wheel_c,wheel_d)
def deep_drawer(w=521,d=375,h=202,t=3):
return s3d.group(&class="tok-comment">#39;deep_drawer39;, drawer_sheet(w=w,d=d,h=h,t=t))
def drawer_sheet(w,d,h,t):
tray=s3d.box(&class="tok-comment">#39;drawer_pan39;, w-12,d-40,h-8)
s3d.shell(tray,t=t,open=&class="tok-comment">#39;top39;)
tray=s3d.at(tray,x=-6)
front=s3d.at(s3d.box(&class="tok-comment">#39;drawer_front39;,t,d,h),x=w/2-9-t/2)
pull=s3d.at(s3d.box(&class="tok-comment">#39;pull39;,8,d-12,8),x=w/2-4,z=h-34)
if h>250:
second=s3d.at(s3d.copy(pull),z=34)
s3d.join(tray,second)
s3d.material(tray,&class="tok-comment">#39;brushed_steelclass="tok-string">39;,color=39;#a5a8aa39;)
s3d.material(front,&class="tok-comment">#39;brushed_steelclass="tok-string">39;,color=39;#a5a8aa39;)
s3d.material(pull,&class="tok-comment">#39;brushed_steelclass="tok-string">39;,color=39;#a5a8aa39;)
return s3d.join(tray,front,pull)
def middle_drawer(w=521,d=375,h=113,t=3):
return s3d.group(&class="tok-comment">#39;middle_drawer39;, drawer_sheet(w=w,d=d,h=h,t=t))
def broad_upper_drawer(w=521,d=375,h=224,t=3):
return s3d.group(&class="tok-comment">#39;broad_upper_drawer39;, drawer_sheet(w=w,d=d,h=h,t=t))
def broad_lower_drawer(w=523,d=375,h=313,t=3):
return s3d.group(&class="tok-comment">#39;broad_lower_drawer39;, drawer_sheet(w=w,d=d,h=h,t=t))
def top_drawer(w=521,d=375,h=113,t=3):
return s3d.group(&class="tok-comment">#39;top_drawer39;, drawer_sheet(w=w,d=d,h=h,t=t))
def intermediate_drawer(w=521,d=375,h=113,t=3):
return s3d.group(&class="tok-comment">#39;intermediate_drawer39;, drawer_sheet(w=w,d=d,h=h,t=t))
def end_caster(w=38,d=135,h=92,joint_name=&class="tok-comment">#39;joint_tire_01_joint_0039;):
solid=s3d.group(&class="tok-comment">#39;fork_frame39;,caster_fork(w=w,d=d,h=h))
tire=s3d.at(end_tire(),y=16,z=-21)
s3d.joint(joint_name,tire,s3d.local(solid,x=-3,y=15,z=26),kind=&class="tok-comment">#39;continuousclass="tok-string">39;,axis=39;+X39;)
return s3d.group(&class="tok-comment">#39;end_caster39;,solid,tire)
def caster_fork(w,d,h):
crown=s3d.at(s3d.cylinder(&class="tok-comment">#39;swivel39;,d=w,h=12),y=d/2-w/2,z=h-12)
cheek=s3d.extrude(&class="tok-comment">#39;fork39;,s3d.poly([(-22,0),(30,10),(38,65),(5,75),(-23,35)]),h=4)
cheek=s3d.at(cheek,x=-w/2,y=10,z=0,rx=90,rz=90)
twin=s3d.transform(s3d.copy(cheek),mirror=&class="tok-comment">#39;x39;)
tab=s3d.at(s3d.box(&class="tok-comment">#39;brake39;,w-6,75,5),y=-d/2+75/2,z=h-28)
s3d.join(crown,cheek,twin,tab)
s3d.material(crown,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#92999b39;)
return crown
def end_tire(w=26,d=95,h=92):
return s3d.group(&class="tok-comment">#39;end_tire39;,wheel_disc(w=w,d=h))
def wheel_disc(w,d):
disc=s3d.cylinder(&class="tok-comment">#39;tire39;,d=d,h=w)
s3d.fillet(disc,r=5,edges=&class="tok-comment">#39;all39;)
disc=s3d.at(disc,x=-w/2,z=d/2,ry=90)
s3d.material(disc,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#454a4c39;)
return disc
def shelf_caster(w=38,d=135,h=92,joint_name=&class="tok-comment">#39;joint_tire_03_joint_0039;):
solid=s3d.group(&class="tok-comment">#39;fork_frame39;,caster_fork(w=w,d=d,h=h))
tire=s3d.at(shelf_tire(),y=16,z=-21)
s3d.joint(joint_name,tire,s3d.local(solid,x=-3,y=15,z=26),kind=&class="tok-comment">#39;continuousclass="tok-string">39;,axis=39;+X39;)
return s3d.group(&class="tok-comment">#39;shelf_caster39;,solid,tire)
def shelf_tire(w=26,d=95,h=92):
return s3d.group(&class="tok-comment">#39;shelf_tire39;,wheel_disc(w=w,d=h))