From ca9783df5dc645a027743902f7f3b2e0348fd716 Mon Sep 17 00:00:00 2001 From: Joshua Shreve Date: Wed, 11 Aug 2021 20:55:08 -0400 Subject: Interim checkin. Initial version of trackball webs/walls in, still working on component cut/union order. Fixed base plates and walls to be identical in caquery and solid. Fixed if/elif/else structure that misplaced the MINI cluster screw mount. Added intial pass at add on PCB as option to add with caps for interference checks. Moved bottom_hull to helper libraries as they are specific to engine. Fixed bottom_hull functions to correct minor discrepency between the engines. Fixed solid intersect function. --- src/dactyl_manuform.py | 386 +++++++++++++++++++++++++----------------- src/generate_configuration.py | 30 +++- src/helpers_cadquery.py | 33 ++++ src/helpers_solid.py | 17 +- src/run_config.json | 24 ++- 5 files changed, 316 insertions(+), 174 deletions(-) diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py index 3379fb9..d734684 100644 --- a/src/dactyl_manuform.py +++ b/src/dactyl_manuform.py @@ -348,8 +348,25 @@ def sa_cap(Usize=1): key_cap = translate(key_cap, (0, 0, 5 + plate_thickness)) + if show_pcbs: + key_cap = add([key_cap, key_pcb()]) + return key_cap +def key_pcb(): + shape = box(pcb_width, pcb_height, pcb_thickness) + shape = translate(shape, (0, 0, -pcb_thickness/2)) + hole = cylinder(pcb_hole_diameter/2, pcb_thickness+.2) + hole = translate(hole, (0, 0, -(pcb_thickness+.1)/2)) + holes = [ + translate(hole, (pcb_hole_pattern_width/2, pcb_hole_pattern_height/2, 0)), + translate(hole, (-pcb_hole_pattern_width / 2, pcb_hole_pattern_height / 2, 0)), + translate(hole, (-pcb_hole_pattern_width / 2, -pcb_hole_pattern_height / 2, 0)), + translate(hole, (pcb_hole_pattern_width / 2, -pcb_hole_pattern_height / 2, 0)), + ] + shape = difference(shape, holes) + + return shape ######################### ## Placement Functions ## @@ -589,14 +606,6 @@ def thumborigin(): return origin -def thumb_tr_place(shape): - debugprint('thumb_tr_place()') - shape = rotate(shape, [10, -15, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-12, -16, 3]) - return shape - - def thumb_tl_place(shape): debugprint('thumb_tl_place()') shape = rotate(shape, [7.5, -18, 10]) @@ -605,6 +614,13 @@ def thumb_tl_place(shape): return shape +def thumb_tr_place(shape): + debugprint('thumb_tr_place()') + shape = rotate(shape, [10, -15, 10]) + shape = translate(shape, thumborigin()) + shape = translate(shape, [-12, -16, 3]) + return shape + def thumb_mr_place(shape): debugprint('thumb_mr_place()') shape = rotate(shape, [-6, -34, 48]) @@ -1712,48 +1728,48 @@ def trackball_place(shape): def trackball_thumb_tl_place(shape): debugprint('thumb_tr_place()') - shape = rotate(shape, [10, -5, 25]) + shape = rotate(shape, [5, 10, -65]) shape = translate(shape, thumborigin()) - shape = translate(shape, [-14, -10, 0]) + shape = translate(shape, [-14, -9, 0]) return shape def trackball_thumb_mr_place(shape): debugprint('thumb_mr_place()') - shape = rotate(shape, [-7, -20, 75]) + shape = rotate(shape, [7, 20, -105]) shape = translate(shape, thumborigin()) - shape = translate(shape, [-13, -32, -5]) + shape = translate(shape, [-12, -32, -5]) return shape def trackball_thumb_br_place(shape): debugprint('thumb_br_place()') - shape = rotate(shape, [-10, -25, 90]) + shape = rotate(shape, [25, -11, 0]) shape = translate(shape, thumborigin()) - shape = translate(shape, [-40, -48, -16]) + shape = translate(shape, [-40, -50, -16]) return shape def trackball_thumb_bl_place(shape): debugprint('thumb_bl_place()') - shape = rotate(shape, [0, -25, 45]) + shape = rotate(shape, [25, 0, -45]) shape = translate(shape, thumborigin()) - shape = translate(shape, [-60.5, -38.5, -18]) + shape = translate(shape, [-63, -41, -18]) return shape -def trackball_thumb_tlold_place(shape): - debugprint('thumb_tl_place()') - shape = rotate(shape, [7.5, -10, 10]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-32.5, -14.5, -4]) - return shape - - -def trackball_thumb_mlold_place(shape): - debugprint('thumb_ml_place()') - shape = rotate(shape, [6, -34, 40]) - shape = translate(shape, thumborigin()) - shape = translate(shape, [-51, -25, -12]) - return shape +# def trackball_thumb_tlold_place(shape): +# debugprint('thumb_tl_place()') +# shape = rotate(shape, [7.5, -10, 10]) +# shape = translate(shape, thumborigin()) +# shape = translate(shape, [-32.5, -14.5, -4]) +# return shape +# +# +# def trackball_thumb_mlold_place(shape): +# debugprint('thumb_ml_place()') +# shape = rotate(shape, [6, -34, 40]) +# shape = translate(shape, thumborigin()) +# shape = translate(shape, [-51, -25, -12]) +# return shape def trackball_thumb_1x_layout(shape): @@ -1794,7 +1810,7 @@ def trackball_thumb(side="right"): shape = union([shape, trackball_thumb_fx_layout(double_plate())]) shape = union([shape, trackball_thumb_1x_layout(single_plate(side=side))]) - shape = union([shape, trackball_layout(trackball_socket())]) + # shape = union([shape, trackball_layout(trackball_socket())]) # shape = trackball_thumb_1x_layout(single_plate(side=side)) return shape @@ -1829,7 +1845,7 @@ def trackball_thumb_post_br(): def trackball_post_r(): debugprint('trackball_post_r()') - radius = ball_diameter/2+ball_wall_thickness + radius = ball_diameter/2 + ball_wall_thickness + ball_gap return translate(web_post(), [1.0*(radius - post_adj), 0.0*(radius - post_adj), 0] ) @@ -1837,7 +1853,7 @@ def trackball_post_r(): def trackball_post_tr(): debugprint('trackball_post_tr()') - radius = ball_diameter/2+ball_wall_thickness + radius = ball_diameter/2+ball_wall_thickness + ball_gap return translate(web_post(), [0.5*(radius - post_adj), 0.866*(radius - post_adj), 0] ) @@ -1845,7 +1861,7 @@ def trackball_post_tr(): def trackball_post_tl(): debugprint('trackball_post_tl()') - radius = ball_diameter/2+ball_wall_thickness + radius = ball_diameter/2+ball_wall_thickness + ball_gap return translate(web_post(), [-0.5*(radius - post_adj), 0.866*(radius - post_adj), 0] ) @@ -1853,14 +1869,14 @@ def trackball_post_tl(): def trackball_post_l(): debugprint('trackball_post_l()') - radius = ball_diameter/2+ball_wall_thickness + radius = ball_diameter/2+ball_wall_thickness + ball_gap return translate(web_post(), [-1.0*(radius - post_adj), 0.0*(radius - post_adj), 0] ) def trackball_post_bl(): debugprint('trackball_post_bl()') - radius = ball_diameter/2+ball_wall_thickness + radius = ball_diameter/2+ball_wall_thickness + ball_gap return translate(web_post(), [-0.5*(radius - post_adj), -0.866*(radius - post_adj), 0] ) @@ -1868,7 +1884,7 @@ def trackball_post_bl(): def trackball_post_br(): debugprint('trackball_post_br()') - radius = ball_diameter/2+ball_wall_thickness + radius = ball_diameter/2+ball_wall_thickness + ball_gap return translate(web_post(), [0.5*(radius - post_adj), -0.866*(radius - post_adj), 0] ) @@ -1879,53 +1895,91 @@ def trackball_thumb_connectors(): print('thumb_connectors()') hulls = [] - # # Top two - # hulls.append( - # triangle_hulls( - # [ - # trackball_thumb_tlold_place(trackball_thumb_post_tr()), - # trackball_thumb_tlold_place(trackball_thumb_post_br()), - # trackball_thumb_tl_place(web_post_tl()), - # trackball_thumb_tl_place(web_post_bl()), - # ] - # ) - # ) - # - # # bottom two on the right - # hulls.append( - # triangle_hulls( - # [ - # trackball_thumb_br_place(web_post_tr()), - # trackball_thumb_br_place(web_post_br()), - # trackball_thumb_mr_place(web_post_tl()), - # trackball_thumb_mr_place(web_post_bl()), - # ] - # ) - # ) - # - # # bottom two on the left - # hulls.append( - # triangle_hulls( - # [ - # trackball_thumb_br_place(web_post_tr()), - # trackball_thumb_br_place(web_post_br()), - # trackball_thumb_mr_place(web_post_tl()), - # trackball_thumb_mr_place(web_post_bl()), - # ] - # ) - # ) - # # centers of the bottom four - # hulls.append( - # triangle_hulls( - # [ - # trackball_thumb_bl_place(web_post_tr()), - # trackball_thumb_bl_place(web_post_br()), - # trackball_thumb_mlold_place(web_post_tl()), - # trackball_thumb_mlold_place(web_post_bl()), - # ] - # ) + # bottom 2 to tb + hulls.append( + triangle_hulls( + [ + trackball_place(trackball_post_l()), + trackball_thumb_bl_place(web_post_tl()), + trackball_place(trackball_post_bl()), + trackball_thumb_bl_place(web_post_tr()), + trackball_thumb_br_place(web_post_tl()), + trackball_place(trackball_post_bl()), + trackball_thumb_br_place(web_post_tr()), + trackball_place(trackball_post_br()), + trackball_thumb_br_place(web_post_tr()), + trackball_place(trackball_post_br()), + trackball_thumb_mr_place(web_post_br()), + trackball_place(trackball_post_r()), + trackball_thumb_mr_place(web_post_bl()), + trackball_thumb_tl_place(web_post_br()), + trackball_place(trackball_post_r()), + trackball_thumb_tl_place(web_post_bl()), + trackball_place(trackball_post_tr()), + key_place(web_post_bl(), 0, cornerrow), + trackball_place(trackball_post_tl()), + ] + ) + ) + + # bottom left + hulls.append( + triangle_hulls( + [ + trackball_thumb_bl_place(web_post_tr()), + trackball_thumb_br_place(web_post_tl()), + trackball_thumb_bl_place(web_post_br()), + trackball_thumb_br_place(web_post_bl()), + ] + ) + ) + + # bottom right + hulls.append( + triangle_hulls( + [ + trackball_thumb_br_place(web_post_tr()), + trackball_thumb_mr_place(web_post_br()), + trackball_thumb_br_place(web_post_br()), + trackball_thumb_mr_place(web_post_tr()), + ] + ) + ) + # top right + hulls.append( + triangle_hulls( + [ + trackball_thumb_mr_place(web_post_bl()), + trackball_thumb_tl_place(web_post_br()), + trackball_thumb_mr_place(web_post_tl()), + trackball_thumb_tl_place(web_post_tr()), + ] + ) + ) + # top right + hulls.append( + triangle_hulls( + [ + key_place(web_post_bl(), 0, cornerrow), + left_key_place(web_post(), lastrow - 1, -1, side=ball_side, low_corner=True), # left_key_place(translate(web_post(), wall_locate1(-1, 0)), cornerrow, -1, low_corner=True), + trackball_place(trackball_post_tl()), + ] + ) + ) + + # temp_shape1 = wall_brace( + # (lambda sh: left_key_place(sh, y, 1, side=side)), -1, 0, web_post(), + # (lambda sh: left_key_place(sh, y, -1, low_corner=low, side=side)), -1, 0, web_post(), # ) - # + # temp_shape2 = hull_from_shapes(( + # key_place(web_post_tl(), 0, y), + # key_place(web_post_bl(), 0, y), + # left_key_place(web_post(), y, 1, side=side), + # left_key_place(web_post(), y, -1, low_corner=low, side=side), + # )) + # shape = union([shape, temp_shape1]) + # shape = union([shape, temp_shape2]) + # # top two to the middle two, starting on the left # hulls.append( # triangle_hulls( @@ -1961,20 +2015,25 @@ def trackball_thumb_connectors(): hulls.append( triangle_hulls( [ - # trackball_thumb_tlold_place(trackball_thumb_post_tl()), key_place(web_post_bl(), 0, cornerrow), - trackball_thumb_tlold_place(trackball_thumb_post_tr()), + trackball_thumb_tl_place(web_post_bl()), key_place(web_post_br(), 0, cornerrow), trackball_thumb_tl_place(web_post_tl()), key_place(web_post_bl(), 1, cornerrow), - trackball_thumb_tl_place(web_post_tr()), + trackball_thumb_tl_place(web_post_tl()), key_place(web_post_br(), 1, cornerrow), + trackball_thumb_tl_place(web_post_tr()), key_place(web_post_tl(), 2, lastrow), key_place(web_post_bl(), 2, lastrow), trackball_thumb_tl_place(web_post_tr()), key_place(web_post_bl(), 2, lastrow), - trackball_thumb_tl_place(web_post_br()), + trackball_thumb_mr_place(web_post_tl()), key_place(web_post_br(), 2, lastrow), + key_place(web_post_bl(), 3, lastrow), + trackball_thumb_mr_place(web_post_tr()), + trackball_thumb_mr_place(web_post_tl()), + key_place(web_post_br(), 2, lastrow), + key_place(web_post_bl(), 3, lastrow), key_place(web_post_tr(), 2, lastrow), key_place(web_post_tl(), 3, lastrow), @@ -1985,6 +2044,7 @@ def trackball_thumb_connectors(): ] ) ) + # trackball_place(trackball_thumb_post_tl()), hulls.append( triangle_hulls( @@ -2017,60 +2077,26 @@ def trackball_thumb_connectors(): ## Case ## ########## - -def bottom_hull(p, height=0.001): - debugprint("bottom_hull()") - if ENGINE == 'cadquery': - shape = None - for item in p: - vertices = [] - verts = item.faces('