import sand3d as s3d
def cabinet():
root = s3d.at(body_01(), x=-1)
return s3d.assembly(class="tok-string">"cabinet", root)
def body_01(w=372, d=826, h=877, bottom=13, radius=40, wall=10, cap=40, back=10, foot_w=343, foot_d=71, foot_y=307, panel_w=270, panel_h=663, panel_x=-51, panel_z=107, divider_t=20, track_z=625, track_pitch=32, row_pitch=153, track_t=6):
outer = s3d.at(s3d.extrude(class="tok-string">"case", s3d.rect(w=d-8, d=h-bottom, r=radius), h=w), x=-w/2, z=(h+bottom)/2, rx=90, rz=90)
tool = s3d.at(s3d.extrude(class="tok-string">"interior", s3d.rect(w=d-2*wall, d=h-bottom-2*cap, r=radius-divider_t), h=w), x=-w/2+back, z=(h+bottom)/2, rx=90, rz=90)
outer = s3d.cut(outer, tool)
divider = s3d.at(s3d.box(class="tok-string">"divider", w=w-2*divider_t, d=divider_t, h=h-bottom-2*cap+wall), z=bottom+cap-wall/2)
shelf = s3d.at(s3d.box(class="tok-string">"shelf", w=w-2*divider_t, d=d-2*wall+wall/2, h=divider_t/2), z=542)
shelf2 = s3d.at(s3d.copy(shelf), z=695)
feet = s3d.at(s3d.box(class="tok-string">"skid", w=foot_w, d=foot_d, h=bottom+divider_t/2), on=s3d.grid(nx=1, ny=2, py=2*foot_y))
panel = s3d.extrude(class="tok-string">"side_inset", s3d.rect(w=panel_w, d=panel_h, r=divider_t), h=divider_t/2)
panel = s3d.at(panel, x=panel_x, y=d/2, z=panel_z+panel_h/2, rx=90)
panel2 = s3d.at(s3d.copy(panel), y=-d/2+divider_t/2)
outer = s3d.join(outer, panel, panel2, feet, divider, shelf, shelf2)
for y in [divider_t, -divider_t, d/2-wall-divider_t/2, -d/2+wall+divider_t/2]:
for z in [track_z, track_z+track_pitch, track_z+row_pitch, track_z+row_pitch+track_pitch]:
rail = s3d.at(s3d.box(class="tok-string">"track", w=w-2*divider_t, d=divider_t+track_t, h=track_t), y=y, z=z)
outer = s3d.join(outer, rail)
s3d.material(outer, class="tok-string">"painted_metal", color=class="tok-string">"class="tok-comment">#969995")
a = s3d.at(drawer_04(), x=5, y=199.5, z=552)
b = s3d.at(drawer_02(), x=5, y=199.5, z=705)
c = s3d.at(door_01(), x=178.5, y=-204, z=23)
e = s3d.at(door_02(), x=178.5, y=204, z=23)
f = s3d.at(drawer_03(), x=5, y=-199.5, z=552)
g = s3d.at(drawer_01(), x=5, y=-199.5, z=705)
root = s3d.group(class="tok-string">"body_01", outer, a, b, c, e, f, g)
s3d.joint(class="tok-string">"joint_drawer_04_joint_00", a, s3d.local(root, x=18, y=198, z=607), kind=class="tok-string">"prismatic", axis=class="tok-string">"+X", range=(-1,300))
s3d.joint(class="tok-string">"joint_drawer_02_joint_00", b, s3d.local(root, x=20, y=198, z=757), kind=class="tok-string">"prismatic", axis=class="tok-string">"+X", range=(-1,300))
s3d.joint(class="tok-string">"joint_door_01_joint_00", c, s3d.local(root, x=181, y=-406, z=292), axis=class="tok-string">"+Z", range=(-90,0))
s3d.joint(class="tok-string">"joint_door_02_joint_00", e, s3d.local(root, x=181, y=406, z=292), axis=class="tok-string">"+Z", range=(0,90))
s3d.joint(class="tok-string">"joint_drawer_03_joint_00", f, s3d.local(root, x=18, y=-198, z=607), kind=class="tok-string">"prismatic", axis=class="tok-string">"+X", range=(-1,300))
s3d.joint(class="tok-string">"joint_drawer_01_joint_00", g, s3d.local(root, x=20, y=-198, z=757), kind=class="tok-string">"prismatic", axis=class="tok-string">"+X", range=(-1,300))
return root
def drawer_04(w=366, d=397, h=149):
return s3d.group(class="tok-string">"drawer_04", drawer_shape(w=w, d=d, h=h))
def drawer_shape(w, d, h, front=19, wall=6, inset=25, tray_h=108, pull_l=170, pull_d=25, pull_z=91, floor=15, rail_h=35, rail_z=48):
face = s3d.at(s3d.box(class="tok-string">"front", w=front, d=d, h=h), x=(w-front)/2)
s3d.pocket(face, s3d.slot(l=pull_l, d=pull_d), depth=6, on=s3d.local(face, x=front/2, z=pull_z, rx=90, rz=90))
tray = s3d.extrude(class="tok-string">"tray", s3d.rect(w=w-front, d=d-2*inset, r=15), h=tray_h)
tray = s3d.shell(tray, t=wall, open=class="tok-string">"top")
tray = s3d.at(tray, x=-front/2, z=floor)
rails = s3d.at(s3d.box(class="tok-string">"slide", w=w-front, d=wall*2, h=rail_h), on=s3d.grid(nx=1, ny=2, py=d-2*inset), x=-front/2, z=rail_z)
result = s3d.join(face, tray, rails)
s3d.material(result, class="tok-string">"painted_metal", color=class="tok-string">"class="tok-comment">#969995")
return result
def drawer_02(w=366, d=397, h=161):
return s3d.group(class="tok-string">"drawer_02", drawer_shape(w=w, d=d, h=h))
def door_01(w=19, d=406, h=526):
return s3d.group(class="tok-string">"door_01", door_shape(w=w, d=d, h=h, handle_y=156))
def door_shape(w, d, h, handle_y, pull_l=145, pull_d=25, pull_z=269):
panel = s3d.box(class="tok-string">"door", w=w, d=d, h=h)
panel = s3d.fillet(panel, r=2)
s3d.pocket(panel, s3d.slot(l=pull_l, d=pull_d), depth=6, on=s3d.local(panel, x=w/2, y=handle_y, z=pull_z, ry=90))
s3d.material(panel, class="tok-string">"painted_metal", color=class="tok-string">"class="tok-comment">#969995")
return panel
def door_02(w=19, d=406, h=526):
return s3d.group(class="tok-string">"door_02", door_shape(w=w, d=d, h=h, handle_y=-156))
def drawer_03(w=366, d=397, h=149):
return s3d.group(class="tok-string">"drawer_03", drawer_shape(w=w, d=d, h=h))
def drawer_01(w=366, d=397, h=161):
return s3d.group(class="tok-string">"drawer_01", drawer_shape(w=w, d=d, h=h))