GuitarModels/CFTubes/common.scad

146 lines
5.2 KiB
OpenSCAD
Raw Normal View History

2025-01-02 15:11:48 +10:30
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);
}
}
}
2025-01-03 18:20:30 +10:30
module CFTubeCutout2(v, block_y0, block_y1, tolerance = CF_Tube_OD_tolerance, VLH = false, taper_length = 2, taper_mul = 1.1) {
// Alternate approach: supply start vector v, and the bounding y values of the piece, taper on entry points only.
tolerance = tolerance + (VLH ? 0.3 : 0);
tube_y0 = v[1];
tube_y1 = tube_y0 + CF_Tube_Len;
OD = CF_Tube_OD + tolerance;
taper_OD = (CF_Tube_OD*taper_mul) + tolerance;
fn = 360;
// Full cylinder, unconditional
translate(v)
rotate([-90,0,0]) cylinder(h=CF_Tube_Len, d=OD, $fn=fn);
// Check for tapered holes
if ((block_y0 >= tube_y0) && (block_y0 < tube_y1)) // Tube protrudes through start of block
hull() {
translate([v[0], block_y0, v[2]])
rotate([-90,0,0]) cylinder(h=hull_epsilon, d=taper_OD, $fn=fn);
translate([v[0], block_y0+taper_length, v[2]])
rotate([-90,0,0]) cylinder(h=hull_epsilon, d=OD, $fn=fn);
}
if ((block_y1 <= tube_y1) && (block_y1 > tube_y0)) // Tube protrudes through end of block
hull() {
translate([v[0], block_y1-hull_epsilon, v[2]])
rotate([-90,0,0]) cylinder(h=hull_epsilon, d=taper_OD, $fn=fn);
translate([v[0], block_y1-hull_epsilon-taper_length, v[2]])
rotate([-90,0,0]) cylinder(h=hull_epsilon, d=OD, $fn=fn);
}
}
module CFSquareCutout2(v, block_y0, block_y1, tolerance = CF_Square_Width_tolerance, taper_length = 2, taper_mul = 1.1) {
w = CF_Square_Width + tolerance;
taper_w = (CF_Square_Width * taper_mul) + tolerance;
tube_y0 = v[1];
tube_y1 = tube_y0 + CF_Tube_Len;
// Full square rod, unconditional
translate([v[0]-w/2, v[1], v[2]-w/2]) cube([w, CF_Tube_Len, w]);
// Check for tapered holes
if ((block_y0 >= tube_y0) && (block_y0 < tube_y1)) // Tube protrudes through start of block
hull() {
translate([v[0], block_y0, v[2]])
cube([taper_w, hull_epsilon*2, taper_w], center=true);
translate([v[0], block_y0+taper_length, v[2]])
cube([w, hull_epsilon*2, w], center=true);
}
if ((block_y1 <= tube_y1) && (block_y1 > tube_y0)) // Tube protrudes through end of block
hull() {
translate([v[0], block_y1-hull_epsilon, v[2]])
cube([taper_w, hull_epsilon*2, taper_w], center=true);
translate([v[0], block_y1-hull_epsilon-taper_length, v[2]])
cube([w, hull_epsilon*2, w], center=true);
}
// if (taper_x1) {
// hull() {
// translate([0, x1, 0])
// cube([w*taper_mul, hull_epsilon, w*taper_mul], center=true);
// translate([0, x1+(taper_length*taper_direction), 0])
// cube([w, hull_epsilon, w], center=true);
// }
// }
// if (taper_x2){
// hull() {
// translate([0, x2, 0])
// cube([w*taper_mul, hull_epsilon, w*taper_mul], center=true);
// translate([0, x2-(taper_length*taper_direction), 0])
// cube([w, hull_epsilon, w], center=true);
// }
// }
}