// -*- C -*- include tube_dia = 22.4; hinge_around = 2.5; hinge_pin = 1.8 + 0.75; main_th = 3; minor_wall_min = 1; screw = 5.0 + 0.75; screw_head = 8.7 + 1.2; screw_nut_across = 7.9 + 0.75; screw_nut_th = 3.9 + 0.75; screw_head_h = 3.6 + 0.75; knob_behind_across = 12.2 + 0.75; behind_knob_th = 5; clamp_width = 20; clamp_gap = 2; lower_th = 1; overlap_l = 0.1; bridge_slop = 1.2; hinge_lobes = 2; hinge_gap_z = 0.75; hinge_gap_xy = 0.75; $fs = 0.1; $fa = 5; bank_eps_bbox_x = [149, 598]; bank_eps_bbox_y = [274, 1452]; bank_y_sz = 102.25 + 0.50; bank_x_sz = (24.9 + 0.5); bank_recess_y = 5; strap_th = 3; strap_above = 2.5; retainer_walls = [18, 30]; // calculated endwall_th = main_th; bank_recess_dx = minor_wall_min; pspt_to_mm = 25.4 / 72; hinge_stride = (clamp_width + hinge_gap_z) / hinge_lobes; main_r = tube_dia/2 + main_th; hinge_outer_r = hinge_around + hinge_pin/2; hinge_y = tube_dia/2 + hinge_outer_r; screw_max_y_lhs = -main_r -screw_nut_across/2; screw_max_y_rhs = -main_r -knob_behind_across/2; screw_y = min(screw_max_y_lhs, screw_max_y_rhs); bot_y = screw_y -max( screw_nut_across, knob_behind_across/2 ) -minor_wall_min; holder_x_sz = bank_x_sz + bank_recess_dx*2; bank_bot_y = strap_above + strap_th; strap_r = strap_th; echo(bot_y); module TubePlan(){ circle(r = tube_dia/2); } module HingePinPlan(){ translate([0, hinge_y]) circle(r= hinge_pin/2); } module HingeBodyPlan(){ translate([0, hinge_y]) circle(r= hinge_outer_r); } module TubeClampLeftPlan(){ difference(){ union(){ polygon([[ 0, hinge_y + hinge_outer_r ], [ -main_r + overlap_l, hinge_y + hinge_outer_r ], [ -main_r + overlap_l, bot_y ], [ -clamp_gap/2, bot_y ], [ -clamp_gap/2, 0, ], [ 0, 0, ], ]); HingeBodyPlan(); } TubePlan(); HingePinPlan(); } } module TubeClampLeft() { ////toplevel linextr(-clamp_width/2, clamp_width/2) TubeClampLeftPlan(); } module TubeClampRightPlan(){ difference(){ union(){ rectfromto([ clamp_gap/2, bot_y ], [ clamp_gap/2 + behind_knob_th, 0 ]); intersection(){ circle(r= main_r); union(){ rectfromto([0,0], main_r * [5,5]); rectfromto([ clamp_gap/2, main_r*5 ], main_r * [2,-5]); } } HingeBodyPlan(); } TubePlan(); HingePinPlan(); } } module SomeClamp(hinge_alt=false){ difference(){ linextr(-clamp_width/2, clamp_width/2) children(0); linextr_x_yz(-main_r*5, main_r*5) translate([screw_y, 0]) circle(r= screw/2); for (i=[0 : hinge_lobes-1]) { translate([0, hinge_y, -clamp_width/2 + i * hinge_stride + (hinge_alt ? hinge_stride/2 : 0) ]) linextr(-hinge_gap_z, hinge_stride/2) square(hinge_outer_r*2 + hinge_gap_xy, center=true); } } } module PowerBankItselfSidePlan(){ translate([0, bank_bot_y]) scale( bank_x_sz / ( ( bank_eps_bbox_x[1] - bank_eps_bbox_x[0] ) * pspt_to_mm )) translate(pspt_to_mm * [-0.5 * (bank_eps_bbox_x[0] + bank_eps_bbox_x[1]), -bank_eps_bbox_y[0]]) import("powerbank-anker-10000.dxf", convexity=5); } module PowerBankItself(){ ////toplevel rotate([0,90,0]) linextr_y_xz(-bank_y_sz/2, +bank_y_sz/2) PowerBankItselfSidePlan(); } module PowerBankSidePlan(){ ////toplevel render() difference(){ rectfromto([ -holder_x_sz/2, 0 ], [ +holder_x_sz/2, bank_recess_y + bank_bot_y ]); PowerBankItselfSidePlan(); } } module PowerBankStrapCut(){ ////toplevel difference(){ rectfromto([ -holder_x_sz, -0.05 ], [ +holder_x_sz, strap_th + strap_r ]); hull(){ for (sx=[-1,+1]) { translate([sx * (holder_x_sz/2 - strap_r + 0.1), strap_th + strap_r]) circle(strap_r); } } } } module PowerBankHolderTest(){ ////toplevel difference(){ linextr(-20,20) PowerBankSidePlan(); linextr(0, strap_th) PowerBankStrapCut(); } } module EndRetainer(depth){ ////toplevel translate([0, -bank_y_sz/2, 0]) { linextr_y_xz(-endwall_th, 0) rectfromto([ 0, -holder_x_sz/2 ], [ -depth, +holder_x_sz/2 ]); for (m=[0,1]) { mirror([0,0,m]) { linextr(-holder_x_sz/2, -bank_x_sz/2){ hull(){ rectfromto([ 0, -endwall_th ], [ depth, 0 ]); rectfromto([ 0, 0 ], [ 0.1, depth-0.1 ]); } } } } } } module PowerBankHolder(){ ////toplevel difference(){ union(){ rotate([0,90,0]) linextr_y_xz(-(bank_y_sz/2 + 0.1), +(bank_y_sz/2 + 0.1)) PowerBankSidePlan(); EndRetainer(retainer_walls[0]); mirror([0,1,0]) EndRetainer(retainer_walls[1]); } //linextr(0, strap_th) PowerBankStrapCut(); } } module TubeClampLeft() { ////toplevel // We want this to print with the recess overhand to the right // where the workpiece cooling fan is rotate([0,0,180]){ difference(){ SomeClamp(true) TubeClampLeftPlan(); translate([0, screw_y, 0]) { linextr_x_yz(-(clamp_gap/2 + screw_nut_th), 0) square([screw_nut_across, screw_nut_across / cos(30) + bridge_slop*2], center=true); linextr_x_yz(-main_r, -main_r + screw_head_h) square([screw_head, screw_head + bridge_slop*2], center=true); } } } } module TubeClampRight() { ////toplevel rotate([0,0,180]) rotate([180,0,0]) SomeClamp() TubeClampRightPlan(); } module TubeClampDemo() { ////toplevel TubeClampLeft(); rotate([180,0,0]) TubeClampRight(); }