doggie-door/LBracket_Parametric_rev9.scad

255 lines
7.4 KiB
OpenSCAD
Raw Normal View History

2024-04-03 23:04:36 +00:00
//Parametric L Bracket
//You can make this any length, Width, Height & Thickness you want
//You can also have 1, 2 or 4 screws on each leg of the L
//8/19/2015 By: David Bunch
//
//Revised 8/20/2015 to make rounded ends instead of chamfers
// and more flexibility on screws
//CUSTOMIZER VARIABLES
/* [Basic Dimensions] */
//1. Length of Part along 1st L
Len = 1.75*25.4; //[25:1:75]
//2. Width of L along 2nd L
Wid = 0.65*25.4; //[25:1:75]
//3. Height of L Bracket
Ht = 1*25.4; //[20:1:75]
//4. Thickness of Leg along X-Axis
Thk_X = 0.25*25.4; //[2:.5:12]
//5. Thickness of Leg along Y-axis
Thk_Y = 0.5*25.4; //[2:.5:12]
//6. Weld Diameter at L junction
WeldDia = 0.5*25.4; //[2:.5:12]
//7. Round Corners (0 = No, 1 = Yes)
RndON = 1; //[0:No, 1:Yes]
//8. # of parts to make (1,2,3 or 4)
Parts = 1; //[1:1:4]
/* [Hole Sizes] */
//9. Hole Diameter for Screws (#8 screw default)
HoleSize = 3; //[0:#6, 1:#8, 2:#10, 3:3mm, 4:4mm, 5:5mm, 6:6mm]
//#10 Screws are 4.5 measured
//#8 Screws are 4.2 measured
//#6 Screws are 3.4 measured
//10. Taper or Countersink Hole
Tap_CnkSnk = 1; //[0:None, 1:Tapered, 2:Counter Sink]
//11. Drill Hole Tolerance
Tolerance = .1; //[0:.05:.8]
/* [Hole Offsets] */
//12. 1st Hole Offset distance from end of X-Axis
HoleOffset_X1 = 10; //[6:.5:30]
//13. 2nd Hole Offset distance from 1st Hole of X-Axis
HoleOffset_X2 = 10; //[6:.5:30]
//14. 1st Hole Offset distance from end of Y-Axis
HoleOffset_Y1 = 0.5*25.4; //[6:.5:30]
//15. 2nd Hole Offset distance from 1st Hole of Y-Axis
HoleOffset_Y2 = 10; //[6:.5:30]
/* [Number of Holes] */
//16. # of Screws on each side of L (1 or 2)
Screws_X = 2; //[1:One Screw, 2:Two Screws]
//17. # of Screws on each side of L (1 or 2)
Screws_Y = 1; //[1:One Screw, 2:Two Screws]
//18. # of Screws along Height of L on X-Axis (1 or 2)
Screws_ZX = 1; //[1:One Screw, 2:Two Screws]
//19. # of Screws along Height of L on Y-Axis (1 or 2)
Screws_ZY = 1; //[1:One Screw, 2:Two Screws]
//20. Screw Height (I use 3/4" screws for default)
ScrewHt = 19.0; //[9.5:.5:38]
//CUSTOMIZER VARIABLES END
//HoleSize = 4.2; //[#6:3.4, #8:4.2, #10:4.5, 3mm:3, 4mm:4, 5mm:5, 6mm:6]
// //#10 Screws are 4.5 measured
// //#8 Screws are 4.2 measured
// //#6 Screws are 3.4 measured
//
////10. Taper or Countersink Hole
//Tap_CnkSnk = 1; //[0:None, 1:Tapered, 2:Counter Sink]
//
////11. Dia. of Taper Head of Screw (#8 used for default)
//TaperDia = 7.9; //[6.45:#6, 7.95:#8, 9.0:#10, 6:3mm, 4mm:8, 5mm:10, 6mm:12]
A_Hole_OD = [3.4,4.2,4.5,3,4,5,6];
A_Head_OD = [6.45,7.95,9,6,8,10,12];
A_TaperLen = [2.66,3.5,3.9,3,4.2,5.5,6.5];
HoleOD = A_Hole_OD[HoleSize] + Tolerance; //Calculated Hole Diameter
TapOD = A_Head_OD[HoleSize] + Tolerance; //Calculated Tapered Head Diameter
TaperLen = A_TaperLen[HoleSize];
WeldRad = WeldDia / 2; //Radius of Weld
//Calcs for Hole(s) along X axis
Ht2ZX = Ht / (Screws_ZX + 1); //Half Height or 1/3 height if 2 screws are used
echo("Ht2ZX = ", Ht2ZX);
H_X = (Len - Thk_Y - WeldRad) / (Screws_X + 1);
echo("H_X = ",H_X);
//Hole_X = H_X + Thk_Y + WeldRad;
Hole_X1 = Len - HoleOffset_X1;
Hole_X2 = Hole_X1 - HoleOffset_X2;
echo("Hole_X1 = ",Hole_X1);
//Hole_X2 = Hole_X1 + H_X;
echo("Hole_X2 = ",Hole_X2);
//
//Calcs for Hole(s) along Y axis
Ht2ZY = Ht / (Screws_ZY + 1); //Half Height or 1/3 height if 2 screws are used
echo("Ht2ZY = ", Ht2ZY);
H_Y = (Wid - Thk_X - WeldRad) / (Screws_Y + 1);
echo("H_Y = ",H_Y);
//Hole_Y = H_Y + Thk_X + WeldRad;
Hole_Y1 = Wid - HoleOffset_Y1;
Hole_Y2 = Hole_Y1 - HoleOffset_Y2;
echo("Hole_Y = ",Hole_Y1);
//Hole_Y2 = Hole_Y + H_Y;
echo("Hole_Y2 = ",Hole_Y2);
//
ScrewThreadHt = ScrewHt - TaperLen;
Ht2x = Ht * 2;
Ht_Half = Ht / 2;
Ires = round(((Ht * 3.14) / 4) / .8) * 4;
Hole_Res = round(((TapOD * 3.14) / 4) / 1) * 4;
echo(Hole_Res = Hole_Res);
module DrawSrewCut()
{
//This combines the head to the screw
if (Tap_CnkSnk == 0)
{
cylinder(d=HoleOD,h=ScrewThreadHt,$fn=Hole_Res);
} else if (Tap_CnkSnk == 1)
{
union()
{
cylinder(d1=TapOD,d2=HoleOD,h=TaperLen,$fn=Hole_Res);
cylinder(d=HoleOD,h=ScrewThreadHt,$fn=Hole_Res);
}
} else if (Tap_CnkSnk == 2)
{
union()
{
cylinder(d=TapOD,h=TaperLen,$fn=Hole_Res);
cylinder(d=HoleOD,h=ScrewThreadHt,$fn=Hole_Res);
}
}
}
module LBracket()
{
union()
{
cube([Len,Thk_X,Ht]); //Draw the X axis side
cube([Thk_Y,Wid,Ht]); //Draw the Y axis side
translate([Thk_Y,Thk_X,0])
cylinder(d=WeldDia,h=Ht,$fn=4); //Add the Weld
}
}
module RndCorner_XY()
{
difference()
{
cylinder(d=Ht2x,h=Thk_X+Thk_Y,$fn=Ires);
translate([0,0,-1])
cylinder(d=Ht,h=Thk_X+Thk_Y+2,$fn=Ires);
translate([-(Ht2x+2),-(Ht+1),-1])
cube([Ht2x+2,Ht2x+2,Thk_X+Thk_Y+2]);
}
}
module Screws_X()
{
//Drill holes for Screws along the X axis
translate([Hole_X1,Thk_X+.02,Ht2ZX])
rotate([90,0,0])
DrawSrewCut();
if (Screws_X == 2)
{
translate([Hole_X2,Thk_X+.02,Ht2ZX])
rotate([90,0,0])
DrawSrewCut();
}
}
module Screws_Y()
{
//Drill holes for Screws along the Y axis
translate([Thk_Y+.02,Hole_Y1,Ht2ZY])
rotate([0,-90,0])
DrawSrewCut();
if (Screws_Y == 2)
{
translate([Thk_Y+.02,Hole_Y2,Ht2ZY])
rotate([0,-90,0])
DrawSrewCut();
}
}
module DrawL()
{
rotate([90,0,0])
difference()
{
LBracket();
Screws_X();
if (Screws_ZX == 2)
{
translate([0,0,Ht2ZX])
Screws_X();
}
Screws_Y();
if (Screws_ZY == 2)
{
translate([0,0,Ht2ZY])
Screws_Y();
}
if (RndON == 1)
{
//Round the X-Axis Corner
translate([Len-Ht_Half,-1,Ht_Half])
rotate([-90,0,0])
RndCorner_XY();
//Round the Y-Axis Corner
translate([-1,Wid-Ht_Half,Ht_Half])
rotate([90,0,90])
RndCorner_XY();
}
//The following section is only for visual checks of how far screws go into wood
//These will not draw on final render
translate([0,-12.7,0])
%cube([Hole_X1,12.7,38.1]); //Check how far screw goes into 1/2" wood
translate([-19.02,0,0])
%cube([19.02,Hole_Y1,38.1]); //Check how far screw goes into 3/4" wood
if (Tap_CnkSnk != 0)
{
translate([Hole_X1,Thk_X + 2 + TaperLen,Ht2ZX])
rotate([90,0,0])
color("red")
%DrawSrewCut();
translate([Thk_Y+2+TaperLen,Hole_Y1,Ht2ZY])
rotate([0,-90,0])
color("red")
%DrawSrewCut();
}
}
}
//Draw how ever many parts user wants along the Y-Axis
for ( i = [1 : Parts] )
{
translate([0,(Ht+6) * i,0])
DrawL();
}