This commit is contained in:
2022-06-27 12:12:44 -04:00
commit a29f6d8f94
591 changed files with 5335885 additions and 0 deletions

163
main.py Normal file
View File

@@ -0,0 +1,163 @@
import os
import datetime as dt
print(str(dt.datetime.now()))
import importlib as ir
from cadquery import exporters as et
try:
root_dir = r'C:\\Users\\TheBears\\Seafile\\Designs\\Projects\\kickdrawers\\cadfree\\code\\'
os.chdir(root_dir)
except:
root_dir = r'/home/thebears/Seafile/Designs/Projects/kickdrawers/cadfree/code'
os.chdir(root_dir)
import items as it
import util as u
import cadquery as cq
ir.reload(it)
ir.reload(u)
TEST=True
objs = list()
# Base parameters
add_the_fingers = False
force_tab_width = False
r_hole = 4.6/2
full_width = 1012
slider_thickness = 12.7
t_small = 3.175
t_large = t_small*2
back_padding = 14
box_depth = 540 + 25.4/2
box_height = 3.15*25.4
front_offset_face = 12
prefix = 'orig'
if True : #Under the sink:
box_depth = 465 + 25.4/2
full_width = 790
trans_1 = 165-slider_thickness - 2*t_small - 2*t_large
trans_2 = 230-slider_thickness - 2*t_small + t_large
bdepth = box_depth - 270 - back_padding
# Computed parameters
box_depth_w_pad = box_depth + back_padding
box_width = (full_width - 4*slider_thickness - 2*t_large - 2*t_small)/2
z_drop = t_large + t_small
settings = {'w':box_width, 'd':box_depth, 'h':box_height, 't_large':t_large, 'add_holes':True, 'r_hole':r_hole, 'add_fingers':add_the_fingers}
xy_wp = lambda: cq.Workplane('XY')
t_pan_1 = u.add_rect(xy_wp(), t_large, bdepth).extrude(box_height - 2).translate((trans_1,0,2))
t_pan_2 = u.add_rect(xy_wp(), t_large, bdepth).extrude(box_height - 2).translate((trans_2,0,2))
t_pan_3 = u.add_rect(xy_wp(), trans_2-trans_1+t_large, t_large).extrude(box_height - 2).translate((trans_1,bdepth - t_large,2))
t_slate = u.add_rect(xy_wp(), trans_2 - trans_1 - t_large, bdepth).extrude(100).translate((trans_1+t_large,-t_large,0))
t_slate_2 = u.add_rect(xy_wp(), trans_2 - trans_1 - t_large, bdepth+40).extrude(-200).translate((trans_1+t_large,-t_large - 40,100))
# Make drawers
drawer_1 = it.create_drawer(**settings, tab_override=False ).add_tag('drawer_1');
bottom, b_side, l_side, f_side, r_side = drawer_1
if add_the_fingers:
t_pan_2, t_pan_3 , _ = u.do_fingers(t_pan_2, t_pan_3)
t_pan_1, t_pan_3 , _ = u.do_fingers(t_pan_1, t_pan_3)
bottom, t_pan_1 , _= u.do_fingers(bottom, t_pan_1)
bottom, t_pan_2 , _ = u.do_fingers(bottom, t_pan_2)
bottom, t_pan_3 , _ = u.do_fingers(bottom, t_pan_3, num_tabs=3)
b_side, t_pan_1, _ = u.do_fingers(b_side, t_pan_1)
b_side, t_pan_2, _ = u.do_fingers(b_side, t_pan_2)
bx = it.item_list([])
for b in [bottom, b_side, l_side, f_side, r_side]:
bx.append( b.cut(t_slate) )
objs.append(bx.add_tag('drawer_3'))
objs.append(it.item_list([t_pan_1, t_pan_2, t_pan_3]))
if True:
drawer_2 = it.create_drawer( **settings).translate(box_width+2*slider_thickness+2*t_small,0,0).add_tag('drawer_2');
objs.append(drawer_2)
#Add back panels
xzback = lambda: cq.Workplane(cq.Plane(origin = (-slider_thickness-t_large,-back_padding-t_small,-z_drop), xDir=(1,0,0), normal=(0,-1,0)))
back_1 = u.add_rect(xzback(), full_width/2, box_height + z_drop).extrude(-t_small)
back_2 = u.add_rect(xzback().center(full_width/2,0), full_width/2, box_height + z_drop).extrude(-t_small)
# Add bottom panels
xy_bottom = lambda: cq.Workplane(cq.Plane(origin = (-slider_thickness-t_large,-back_padding-t_small,-z_drop), xDir=(1,0,0), normal=(0,0,1)))
xyb1 = xy_bottom()
bottom_1 = u.add_rect(xyb1, full_width/2, box_depth_w_pad - front_offset_face).extrude(t_small)
bottom_1 = bottom_1.cut( xyb1.pushPoints(u.bottom_points(full_width/2, box_depth_w_pad, grid=[5,5])).circle(r_hole).extrude(10))
bottom_1 = bottom_1.cut(t_slate_2)
back_1 = back_1.cut(t_slate_2)
xyb2 = xy_bottom().center(full_width/2,0)
bottom_2 = u.add_rect(xyb2, full_width/2, box_depth_w_pad - front_offset_face).extrude(t_small)
bottom_2 = bottom_2.cut( xyb2.pushPoints(u.bottom_points(full_width/2, box_depth_w_pad, grid=(5,5))).circle(r_hole).extrude(10))
# Add panels that will hold the drawer slides
yzback = lambda: cq.Workplane('YZ').center(-back_padding-t_small,-z_drop)
panel_a = it.add_panel(yzback(), box_depth_w_pad - front_offset_face, box_height, z_drop, r_hole, -t_small, t_small).translate((-slider_thickness, 0, 0))
panel_b = it.add_panel(yzback(), box_depth_w_pad - front_offset_face, box_height, z_drop, r_hole, t_small, t_small).translate((box_width+slider_thickness, 0, 0))
panel_c = it.add_panel(yzback(), box_depth_w_pad - front_offset_face, box_height, z_drop, r_hole, t_small, t_small).translate((box_width+slider_thickness + t_small, 0, 0))
panel_d = it.add_panel(yzback(), box_depth_w_pad - front_offset_face, box_height, z_drop, r_hole, t_small, t_small).translate((3*slider_thickness + 2*box_width + 2*t_small, 0, 0))
if add_the_fingers:
panel_a, bottom_1, _ = u.do_fingers(panel_a, bottom_1, num_tabs = 13)
panel_b, bottom_1, _ = u.do_fingers(panel_b, bottom_1, num_tabs = 13)
back_1, bottom_1, _ = u.do_fingers(back_1, bottom_1, num_tabs = 13)
panel_a, back_1, _ = u.do_fingers(panel_a, back_1)
panel_b, back_1, _ = u.do_fingers(panel_b, back_1)
panel_c, bottom_2, _ = u.do_fingers(panel_c, bottom_2, num_tabs = 13)
panel_d, bottom_2, _ = u.do_fingers(panel_d, bottom_2, num_tabs = 13)
back_2, bottom_2, _ = u.do_fingers(back_2, bottom_2, num_tabs = 13)
panel_c, back_2, _ = u.do_fingers(panel_c, back_2)
panel_d, back_2, _ = u.do_fingers(panel_d, back_2)
support_1 = it.item_list([back_1, bottom_1, panel_a, panel_b]).add_tag('support_1')
support_2 = it.item_list([back_2, bottom_2, panel_c, panel_d]).add_tag('support_2')
objs.append(support_1)
objs.append(support_2)
for x in objs:
for o in x:
show_object(o)
u.save_stls(objs, os.path.join(root_dir,'under_sink'), prefix)
# fitem = globals().items()
# for name, var in list(globals().items()):
# if var in objs:
# fpath = os.path.join(root_dir, 'base_stls', prefix +'_shell_'+ name+'.stl')
# et.exportShape(var, et.ExportTypes.STL, open(fpath, 'w'))