From 3461ffe57fe8d4026763ab9cf3004cdf2c9b40c2 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Thu, 2 Jan 2025 15:11:48 +1030 Subject: [PATCH] Refactoring CFTubes --- CFTubes.scad | 114 +++++++++++--------------------------------- CFTubes/PETG.scad | 2 + CFTubes/PLA.scad | 2 + CFTubes/common.scad | 75 +++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 85 deletions(-) create mode 100644 CFTubes/PETG.scad create mode 100644 CFTubes/PLA.scad create mode 100644 CFTubes/common.scad diff --git a/CFTubes.scad b/CFTubes.scad index 1796011..40dcd9f 100644 --- a/CFTubes.scad +++ b/CFTubes.scad @@ -1,30 +1,15 @@ include include include + +include +// Choose your material by only including one of the below +// include +include + // Guitar_Scale_Length_mm = 610; // millimetres, slightly over 24inch (609.6mm) Jaguar scale, should be fine for guitar and u-bass // assert(fret_scale_length(0) == 610); // Make sure the function correctly uses our changed global -CF_Tube_Len = 420; // Convenient Amazon size, longer would be better of course but prices are important -CF_Tube_OD = 5.0; // Outer Diameter -CF_Tube_ID = 3.0; -CF_Square_Width = 6.0; -CF_Square_ID = 5.0; // Inner diameter, sadly doesn't fit the tubes - -cyl_hd_fn = $preview ? 32 : 512; -cyl_ld_fn = $preview ? 24 : 72; -module CF_Tube() { // Align +y - rotate([0, 0, 90]) render() difference() { - rotate([0, 90, 0]) cylinder(h=CF_Tube_Len, d=CF_Tube_OD, $fn=cyl_hd_fn); - rotate([0, 90, 0]) cylinder(h=CF_Tube_Len, d=CF_Tube_ID, $fn=cyl_ld_fn); - } -} -module CF_Square() { - rotate([0, 0, 90]) render() difference() { - translate([0, -CF_Square_Width/2, -CF_Square_Width/2]) cube([CF_Tube_Len, CF_Square_Width, CF_Square_Width]); - rotate([0, 90, 0]) cylinder(h=CF_Tube_Len, d=CF_Square_ID, $fn=cyl_ld_fn); - } -} - // Philippians 4:8 // Gideon (ShinKaiYaku07) 真実な, 尊ぶべき, 正しい, 清い, 愛すべき, 評判の良い, 徳とされる, 称賛に値する // ShinKaiYaku65 最後に、兄弟たち。すべての真実なこと、すべての誉れあること、すべての正しいこと、すべてのきよいこと、すべての愛すべきこと、すべての評判の良いこと、そのほか徳と言われること、称賛に値することがあるならば、そのようなことに心を留めなさい。 @@ -32,8 +17,6 @@ module CF_Square() { // going with 良 for 21 fret_inlays = [[3, "真"], [5, "尊"], [7, "正"], [9, "清"], [12, "評判"], [15, "愛"], [17, "徳"], [19, "賛"], [21, "良"], [24, "主イエス"]]; - - module neck(string_spacing=18, string_margin=4.5, num_strings=3, target_neck_thickness=15, scallop_depth=3, num_frets=24, fret_width=2.4, filler=false) { fw2 = fret_width/2; neck_length = fret_scale_length(0)+fw2; @@ -44,7 +27,7 @@ module neck(string_spacing=18, string_margin=4.5, num_strings=3, target_neck_thi a1 = 270+angle_excess; rotate([-90, 0, 0]) linear_extrude(neck_length) - polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width*0.5*sin(a), -target_neck_thickness*cos(a)]]); + polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width*0.5*sin(a), -target_neck_thickness*cos(a)]]); // Ellipse } module scallop(fret) { x0 = fret_scale_length(fret-1) - fw2; @@ -86,11 +69,12 @@ module neck(string_spacing=18, string_margin=4.5, num_strings=3, target_neck_thi x0 = fret_scale_length(fret-1); x1 = fret_scale_length(fret); diff = x0 - x1; - rotate([0, -90, 0]) - translate([0, x1, neck_width/2-3]) + mid = lerp(x0, x1, 0.67); + rotate([0, -94, 0]) + translate([0, mid, neck_width/2-3]) linear_extrude(50) - rotate(-35) - text(text = str(fret), font = JP_Serif_Font, halign = "right", valign = "center", size = 5); + rotate(-37) + text(text = str(fret), font = JP_Serif_Font, halign = "right", valign = "center", size = 4.5); } } } @@ -169,9 +153,9 @@ module tailpiece(string_spacing=18, string_margin=4.5, num_strings=3, target_nec translate([t_offset, 5, t_z]) tuner(); for (i = [-1:2:1]) translate([i*15, 0, -4]) - cf_tube(neck_length, 0, tolerance=0.4); + CFTubeCutout(neck_length, 0, tolerance=0.4); translate([0, 0, -10]) - cf_tube(neck_length, 0, tolerance=0.4); + CFTubeCutout(neck_length, 0, tolerance=0.4); } thick = 34; render() difference() { @@ -181,51 +165,6 @@ module tailpiece(string_spacing=18, string_margin=4.5, num_strings=3, target_nec // color([1,1,1,0.3]) neck_stock(); } -module cf_tube(x1, x2, tolerance = 0.3, VLH = false) { - tolerance = tolerance + (VLH ? 0.3 : 0); - translate([0, x2, 0]) - rotate([-90,0,0]) - cylinder(h=x1-x2, d=CF_Tube_OD+tolerance, $fn=360); - hull() { - translate([0, x2]) - rotate([-90,0,0]) - cylinder(h=0.2, d=CF_Tube_OD*1.2+tolerance, $fn=360); - translate([0, x2+5]) - rotate([-90,0,0]) - cylinder(h=0.2, d=CF_Tube_OD+tolerance, $fn=360); - } - hull() { - translate([0, x1]) - rotate([-90,0,0]) - cylinder(h=0.2, d=CF_Tube_OD*1.2+tolerance, $fn=360); - translate([0, x1-5]) - rotate([-90,0,0]) - cylinder(h=0.2, d=CF_Tube_OD+tolerance, $fn=360); - } -} - -module cf_square(x1, x2, tolerance = 0.2, taper_x1 = true, taper_x2 = true) { - x = CF_Square_Width+tolerance; - translate([-x/2, x2, -x/2]) - cube([x, x1-x2, x]); - if (taper_x1) { - hull() { - translate([0, x1, 0]) - cube([x*1.2, 0.2, x*1.2], center=true); - translate([0, x1-5, 0]) - cube([x, 0.2, x], center=true); - } - } - if (taper_x2){ - hull() { - translate([0, x2, 0]) - cube([x*1.2, 0.2, x*1.2], center=true); - translate([0, x2+5, 0]) - cube([x, 0.2, x], center=true); - } - } -} - module fret_tube(from_fret, to_fret, fret_width=2.4) { fw2 = fret_width/2; x0 = fret_scale_length(0)+fw2; @@ -235,12 +174,12 @@ module fret_tube(from_fret, to_fret, fret_width=2.4) { neck(fret_width=fret_width); for (i = [-1:2:1]) translate([i*15, 0, -4]) - cf_tube(x1, x2); + CFTubeCutout(x1, x2); for (i = [-1:2:1]) translate([i*7.5, 0, -7]) - cf_square(x1, x2); + CFSquareCutout(x1, x2); translate([0, 0, -10]) - cf_tube(x1, x2); + CFTubeCutout(x1, x2); translate([-50, 0, -50]) cube([100, x2, 100]); translate([-50, x1, -50]) cube([100, x0-x1, 100]); @@ -259,7 +198,7 @@ module fret_tube_filler(from_fret, to_fret, fret_width=2.4, belthole_length=140, neck(fret_width=fret_width, filler=true); for (i = [-1:1]) translate([i*15, 0, (i==0)?(-10):(-4)]) - cf_tube(x1, x2, VLH=VLH); + CFTubeCutout(x1, x2, VLH=VLH); translate([-50, 0, -50]) cube([100, x2, 100]); translate([-50, x1, -50]) cube([100, x0-x1, 100]); @@ -332,7 +271,7 @@ module headpiece(string_spacing=18, string_margin=4.5, num_strings=3, target_nec string_tubes(); for (i = [-1:2:1]) translate([i*7.5, 0, -7]) - cf_square(x0+cf_square_length, x0, taper_x1=false); + CFSquareCutout(x0+cf_square_length, x0, taper_x1=false); // αβγδεζ translate([0, x0+headpiece_length, -5]) rotate([90, 0, 180]) linear_extrude(0.3, center=true) text(text = "01β.γ", font = "Deja Vu Sans", halign = "center", valign = "center", size = 4); } @@ -396,7 +335,7 @@ module bridge(string_spacing=18, string_margin=4.5, num_strings=3, target_neck_t string_tubes(); for (i = [-1:1]) translate([i*15, 0, (i==0)?(-10):(-4)]) - cf_tube(piece_length+0.1, x0-0.1, VLH=false); + CFTubeCutout(piece_length+0.1, x0-0.1, VLH=false); // αβγδεζ translate([0, x0+piece_length, -5]) rotate([90, 0, 180]) linear_extrude(0.3, center=true) text(text = "01β", font = "Deja Vu Sans", halign = "center", valign = "center", size = 4); } @@ -405,7 +344,7 @@ module bridge(string_spacing=18, string_margin=4.5, num_strings=3, target_neck_t module Nylon6String() { fsl_mm = fret_scale_length(0); echo(str("Making a Nylon 6 String with scale length ", fsl_mm, "mm = ", fsl_mm/25.4, "in")) - assert(fret_scale_length(0) == Classical_Short_Scale_mm); // Make sure the function correctly uses our changed global + assert(fsl_mm == Classical_Short_Scale_mm); // Make sure the function correctly uses our changed global num_frets = 20; num_strings = 6; @@ -417,14 +356,19 @@ module Nylon6String() { // neck(num_frets=num_frets, num_strings=num_strings, string_margin=string_margin, string_spacing=string_spacing); - module CF_Span(full_length = 700, ply=3) { + module CF_Span(full_length = 700, ply = 3, hole = true) { for (i=[0:ply-1]) - translate([0, lerp(0, full_length-CF_Tube_Len, i/(ply-1)), CF_Square_Width*i]) CF_Square(); + translate([0, lerp(0, full_length-CF_Tube_Len, i/(ply-1)), CF_Square_Width*i]) CFSquare(hole=hole); } for (m=[0,11]) mirror([m, 0, 0]) color([0.4, 0.5, 0.5]) translate([9, -40, -16]) CF_Span(); - // CF_Tube(); + // CFTube(); %neck(num_frets=num_frets, num_strings=num_strings, string_margin=string_margin, string_spacing=string_spacing, scallop_depth=scallop_depth, target_neck_thickness=target_neck_thickness); + // translate([0,0,30]) difference() { + // neck(num_frets=num_frets, num_strings=num_strings, string_margin=string_margin, string_spacing=string_spacing, scallop_depth=scallop_depth, target_neck_thickness=target_neck_thickness); + // for (m=[0,11]) mirror([m, 0, 0]) color([0.4, 0.5, 0.5]) translate([9, -40, -16]) CF_Span(hole=false); + // } + for (m=[0,11]) mirror([m, 0, 0]) translate([29,10,-32]) rotate([0,-90,0]) NylonTuner(); // Debug markers to aid part slicing eyeballing for (i = [150:250:1000]) { diff --git a/CFTubes/PETG.scad b/CFTubes/PETG.scad new file mode 100644 index 0000000..20f71d1 --- /dev/null +++ b/CFTubes/PETG.scad @@ -0,0 +1,2 @@ +CF_Square_Width_tolerance = 0.2; // Untested +CF_Tube_OD_tolerance = 0.3; // Untested diff --git a/CFTubes/PLA.scad b/CFTubes/PLA.scad new file mode 100644 index 0000000..bb35b09 --- /dev/null +++ b/CFTubes/PLA.scad @@ -0,0 +1,2 @@ +CF_Square_Width_tolerance = 0.2; // Add to CF_Square_Width when making holes +CF_Tube_OD_tolerance = 0.3; diff --git a/CFTubes/common.scad b/CFTubes/common.scad new file mode 100644 index 0000000..12c7350 --- /dev/null +++ b/CFTubes/common.scad @@ -0,0 +1,75 @@ +CF_Tube_Len = 420; // Convenient Amazon size, longer would be better of course but prices are important +CF_Tube_OD = 5.0; // Outer Diameter +CF_Tube_ID = 3.0; +CF_Square_Width = 6.0; +CF_Square_ID = 5.0; // Inner diameter, sadly doesn't fit the tubes + +cyl_hd_fn = $preview ? 32 : 512; +cyl_ld_fn = $preview ? 24 : 72; +module CFTube(hole=true) { // Align +y + rotate([0, 0, 90]) render() difference() { + rotate([0, 90, 0]) cylinder(h=CF_Tube_Len, d=CF_Tube_OD, $fn=cyl_hd_fn); + if (hole) rotate([0, 90, 0]) cylinder(h=CF_Tube_Len, d=CF_Tube_ID, $fn=cyl_ld_fn); + } +} +module CFSquare(hole=true) { + rotate([0, 0, 90]) render() difference() { + translate([0, -CF_Square_Width/2, -CF_Square_Width/2]) cube([CF_Tube_Len, CF_Square_Width, CF_Square_Width]); + if (hole) rotate([0, 90, 0]) cylinder(h=CF_Tube_Len, d=CF_Square_ID, $fn=cyl_ld_fn); + } +} + + +hull_epsilon = 0.2; +module CFTubeCutout(x1, x2, tolerance = CF_Tube_OD_tolerance, VLH = false, taper_length = 5) { + tolerance = tolerance + (VLH ? 0.3 : 0); + taper_mul = 1.2; + taper_direction = (x1 > x2) ? (-1) : 1; + x_min = min(x1, x2); + x_max = max(x1, x2); + fn = 360; + translate([0, x_min, 0]) + rotate([-90,0,0]) + cylinder(h=x_max-x_min, d=CF_Tube_OD+tolerance, $fn=fn); + hull() { + translate([0, x1]) + rotate([-90,0,0]) + cylinder(h=hull_epsilon, d=(CF_Tube_OD*taper_mul)+tolerance, $fn=fn); + translate([0, x1+(taper_length*taper_direction)]) + rotate([-90,0,0]) + cylinder(h=hull_epsilon, d=CF_Tube_OD+tolerance, $fn=fn); + } + hull() { + translate([0, x2]) + rotate([-90,0,0]) + cylinder(h=hull_epsilon, d=(CF_Tube_OD*taper_mul)+tolerance, $fn=fn); + translate([0, x2-(taper_length*taper_direction)]) + rotate([-90,0,0]) + cylinder(h=hull_epsilon, d=CF_Tube_OD+tolerance, $fn=fn); + } +} + +module CFSquareCutout(x1, x2, tolerance = CF_Square_Width_tolerance, taper_x1 = true, taper_x2 = true, taper_length = 5) { + x = CF_Square_Width+tolerance; + taper_mul = 1.2; + taper_direction = (x1 > x2) ? (-1) : 1; + x_min = min(x1, x2); + x_max = max(x1, x2); + translate([-x/2, x_min, -x/2]) cube([x, x_max-x_min, x]); + if (taper_x1) { + hull() { + translate([0, x1, 0]) + cube([x*taper_mul, hull_epsilon, x*taper_mul], center=true); + translate([0, x1+(taper_length*taper_direction), 0]) + cube([x, hull_epsilon, x], center=true); + } + } + if (taper_x2){ + hull() { + translate([0, x2, 0]) + cube([x*taper_mul, hull_epsilon, x*taper_mul], center=true); + translate([0, x2-(taper_length*taper_direction), 0]) + cube([x, hull_epsilon, x], center=true); + } + } +}