yacwc
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
import os
|
||||
import datetime as dt
|
||||
print(str(dt.datetime.now()))
|
||||
|
||||
import importlib as ir
|
||||
from cadquery import exporters as et
|
||||
try:
|
||||
try:
|
||||
root_dir = r'C:\\Users\\TheBears\\Seafile\\Designs\\Projects\\kickdrawers\\cadfree\\code\\'
|
||||
os.chdir(root_dir)
|
||||
except:
|
||||
root_dir = r'C:\\Users\\Ishan\\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()
|
||||
|
||||
make_drawer_2 = False
|
||||
|
||||
# Base parameters
|
||||
add_the_fingers = True
|
||||
force_tab_width = False
|
||||
add_holes = True
|
||||
r_hole = 4.6/2
|
||||
#full_width = 1012
|
||||
full_width = 555*2
|
||||
|
||||
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 not make_drawer_2:
|
||||
full_width = full_width - t_large
|
||||
|
||||
|
||||
# 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':add_holes, 'r_hole':r_hole, 'add_fingers':add_the_fingers}
|
||||
|
||||
|
||||
xy_wp = lambda: cq.Workplane('XY')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Make drawers
|
||||
drawer_1 = it.create_drawer(**settings, tab_override=False ).add_tag('drawer_1');
|
||||
|
||||
objs.append(drawer_1)
|
||||
|
||||
if make_drawer_2:
|
||||
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)))
|
||||
yzback = lambda: cq.Workplane('YZ').center(-back_padding-t_small,-z_drop)
|
||||
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()
|
||||
xyb2 = xy_bottom().center(full_width/2,0)
|
||||
|
||||
if make_drawer_2:
|
||||
bottom_1 = u.add_rect(xyb1, full_width/2, box_depth_w_pad - front_offset_face).extrude(t_small)
|
||||
back_1 = u.add_rect(xzback(), full_width/2, box_height + z_drop).extrude(-t_small)
|
||||
else:
|
||||
bottom_1 = u.add_rect(xyb1, full_width/2 + t_small, box_depth_w_pad - front_offset_face).extrude(t_small)
|
||||
back_1 = u.add_rect(xzback(), full_width/2 + t_small, box_height + z_drop).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))
|
||||
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))
|
||||
|
||||
|
||||
if make_drawer_2:
|
||||
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))
|
||||
back_2 = u.add_rect(xzback().center(full_width/2,0), full_width/2, box_height + z_drop).extrude(-t_small)
|
||||
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)
|
||||
|
||||
if make_drawer_2:
|
||||
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')
|
||||
objs.append(support_1)
|
||||
|
||||
if make_drawer_2:
|
||||
support_2 = it.item_list ([back_2, bottom_2, panel_c, panel_d]).add_tag('support_2')
|
||||
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_tea'), 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'))
|
||||
Reference in New Issue
Block a user