Skip to content

Instantly share code, notes, and snippets.

@Robotto
Last active February 24, 2021 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robotto/5ed43e923d6d2340870fd8e16da8df0c to your computer and use it in GitHub Desktop.
Save Robotto/5ed43e923d6d2340870fd8e16da8df0c to your computer and use it in GitHub Desktop.
tubeClamp.scad
$fn = 32; //establish a decent roundness
length = 75;
height = 30;
width = 40;
bigHoleDiameter = 37.5;
filletRadius = 3;
/*
Top view:
________LENGTH________
W| |
I| |
D| x y<+>y x<->|
T| |
H|______________________|
x: clamp screw, and thread insert
y: mounting screw
<->: threadInsert_Clearance
<+>: mountScrew_spacing
*/
threadInsert_holeRadius = 4.5;
threadInsert_holeDepth = 10;
threadInsert_clearance = 4.5;
mountScrew_radius = 3.2;
mountScrew_counterBoreDepth = 15;
mountScrew_counterBoreRadius = 6; //needs to fit a washer, so kinda huge
//mountScrew_nominalLength = 30.5; //not needed, it just sticks out the bottom... but make sure its bigger than mountScrew_clearance
mountScrew_clearance = 4; //thickness from bottom of counterbore to bottom of model
mountScrew_spacing = 8; //horizontal measure of material between the two mountScrew counterbores
clampScrew_radius = 2.25;
clampScrew_counterBoreDepth = 15;
clampScrew_counterBoreRadius = 4.5;
clampScrew_nominalLength = 30.5;
clampScrew_depthIntoBottom = clampScrew_nominalLength - (height - clampScrew_counterBoreDepth);
pilot_Offset = 6;
pilot_xOffset = length/2 - pilot_Offset;
pilot_yOffset = width/2 - pilot_Offset;
//test modules, please ignore:
//translate([length/2 - threadInsert_holeRadius - threadInsert_clearance + 20, 0, height]) threadInsert();
//translate([length/2 - threadInsert_holeRadius - threadInsert_clearance + 40, 0, height * 2]) rotate([180]) clampScrewHole();
//translate([mountScrew_counterBoreRadius + mountScrew_spacing/2, 30, 0]) mountScrewHole();
//translate([ - mountScrew_counterBoreRadius - mountScrew_spacing/2, 30, 0]) mountScrewHole();
bottom();
//top();
translate([0, -5-width, 0]) top();
//put together:
//rotate([0, 180, 0])translate([0, 0, - height * 2]) top();
module top(){
difference(){
makeHull(); //box corners, rounded using hull around cylinders:
//pilot holes:
for ( x = [pilot_xOffset, - 1 * pilot_xOffset]){
for( y = [pilot_yOffset, - 1 * pilot_yOffset]){
translate([x, y, height + 0.5]) rotate([0, 180, 0]) pilotStud();
}
}
//clampScrew holes:
clampScrew_xOffset = length/2 - threadInsert_holeRadius - threadInsert_clearance;
for ( x = [clampScrew_xOffset, - 1 * clampScrew_xOffset]){
translate([x, 0, - 0.1]) clampScrewHole();
}
bigHole();
}
}
module bottom(){
union(){
difference(){
makeHull(); //box corners, rounded using hull around cylinders:
//thread inserts:
insert_xOffset = length/2 - threadInsert_holeRadius - threadInsert_clearance;
for ( x = [insert_xOffset, - 1 * insert_xOffset]){
translate([x, 0, height + 0.1]) threadInsert();
}
//screw holes in the center:
mountScrew_xOffset = mountScrew_counterBoreRadius + mountScrew_spacing/2;
for ( x = [mountScrew_xOffset, - 1 * mountScrew_xOffset]){
translate([x, 0, 0]) mountScrewHole();
}
bigHole();
}
//pilot studs
for ( x = [pilot_xOffset, - 1 * pilot_xOffset]){
for( y = [pilot_yOffset, - 1 * pilot_yOffset]){
translate([x, y, height - 1]) pilotStud();
}
}
}
}
module makeHull(){ //box corners, rounded using hull around spheres:
hull(){
for (z = [filletRadius, height - filletRadius]){ //2 *
for ( y = [width/2 - filletRadius, - width/2 + filletRadius]){ //2 *
for ( x = [length/2 - filletRadius, - length/2 + filletRadius]){ //2 *
translate([x, y, z]) sphere(r = filletRadius); // = 8 spheres
}
}
}
}
}
module bigHole(){
translate([0, 0, height]) rotate([90 , 0 , 0]){
cylinder(h = width, r = bigHoleDiameter/2, center = true);
for( rotation = [0, 180]) {
rotate([rotation, 0, 0]) translate([0, 0, - width/2]) roundFillet(bigHoleDiameter/2);
}
}
fancyRings();
}
module fancyRings(){
for ( yOffset = [0.4, 0.7]){
translate([0, yOffset * width/2, height]) fancyRing();
translate([0, -1 * yOffset * width/2, height]) fancyRing();
}
}
module fancyRing(){
translate([0, -0.9, 0]) rotate([90, 0, 0]) roundFillet(bigHoleDiameter/2 - 1);
translate([0, 0.9, 0]) rotate([ -90, 0, 0]) roundFillet(bigHoleDiameter/2 - 1);
}
module mountScrewHole(){
translate([0, 0, mountScrew_clearance]) cylinder(h = height - mountScrew_clearance, r = mountScrew_counterBoreRadius); //counterbore
cylinder(h = mountScrew_clearance + 0.1, r = mountScrew_radius); //screw
}
module clampScrewHole(){
//head/washer hole:
union(){
cylinder(h = clampScrew_counterBoreDepth, r = clampScrew_counterBoreRadius);
//screw:
translate([0, 0, clampScrew_counterBoreDepth - 0.1]) cylinder(h = clampScrew_nominalLength, r = clampScrew_radius);
roundFillet(clampScrew_counterBoreRadius);
}
}
module threadInsert(){
rotate([180, 0, 0]){
union(){
roundFillet(threadInsert_holeRadius);
hull(){
cylinder(h = threadInsert_holeDepth, r = threadInsert_holeRadius);
cylinder(h = clampScrew_depthIntoBottom , r = clampScrew_radius);
}
}
}
}
module pilotStud(){ //https://bit.ly/3aRcBQo
hull(){
cylinder(h = 1, r = 3);
translate([0, 0, 1]) sphere(2, $fa = 5, $fs = 0.1);
}
}
module cornerCut(){
difference(){
translate([ - filletRadius/3, - filletRadius/3]) square([filletRadius+1, filletRadius+1]);
translate([filletRadius, filletRadius]) circle(filletRadius);
}
}
module roundFillet(r){
rotate_extrude() translate([r, 0]) cornerCut();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment