Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OpenSCAD source code: Mailing tube end cap
// Mailing tube end cap
// Ed Nisley KE4ZNU - June 2017
Layout = "Build";
//- Extrusion parameters - must match reality!
ThreadThick = 0.25;
ThreadWidth = 0.40;
function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
Protrusion = 0.1;
HoleWindage = 0.2;
//- Screw sizes
inch = 25.4;
TubeID = 2 * inch;
TubeWall = 0.1 * inch;
CapInsert = 15.0;
CapRim = 1.0;
CapWall = 3*ThreadWidth;
NumFlanges = 3;
FlangeHeight = 3*ThreadThick;
FlangeWidth = ThreadWidth/2;
FlangeSpace = CapInsert / (NumFlanges + 1);
OAHeight = CapInsert + CapRim;
NumRibs = 3*4;
NumSides = 3*NumRibs;
//- Adjust hole diameter to make the size come out right
module PolyCyl(Dia,Height,ForceSides=0) { // based on nophead's polyholes
Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2);
FixDia = Dia / cos(180/Sides);
cylinder(r=(FixDia + HoleWindage)/2,h=Height,$fn=Sides);
}
module TubeCap() {
difference() {
cylinder(d=TubeID,h=OAHeight,$fn=NumSides);
translate([0,0,CapWall])
cylinder(d=TubeID - 2*CapWall,h=OAHeight,$fn=NumSides);
}
for (i=[1:NumFlanges])
translate([0,0,i*FlangeSpace])
difference() {
cylinder(d=TubeID + 2*FlangeWidth,h=FlangeHeight,$fn=NumSides);
translate([0,0,-Protrusion])
cylinder(d=TubeID - 2*CapWall,h=FlangeHeight + 2*Protrusion,$fn=NumSides);
}
for (i=[0:NumRibs-1])
rotate(i*360/NumRibs)
translate([0,-ThreadWidth,CapWall + ThreadThick])
cube([TubeID/2 - CapWall/2,2*ThreadWidth,CapInsert + CapRim - CapWall - ThreadThick],center=false);
translate([0,0,CapInsert]) {
difference() {
cylinder(d=TubeID + 2*TubeWall,h=CapRim,$fn=NumSides);
translate([0,0,-Protrusion])
cylinder(d=TubeID - 3*2*CapWall,h=2*CapRim,$fn=NumSides);
}
}
}
//- Build things
if (Layout == "Show")
TubeCap();
if (Layout == "Build")
translate([0,0,OAHeight])
rotate([180,0,0])
TubeCap();
@ednisley

This comment has been minimized.

Copy link
Owner Author

@ednisley ednisley commented Jun 12, 2017

More details on my blog at http://wp.me/poZKh-6Qk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.