Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ednisley/ed0787a0a42399f2af49db9e38cf264c to your computer and use it in GitHub Desktop.
Save ednisley/ed0787a0a42399f2af49db9e38cf264c to your computer and use it in GitHub Desktop.
OpenSCAD source code: 3D printed repair tools for Anker LC-40 flashlight
// Anker LC-40 flashlight switch retainer
// Ed Nisley - KE4ZNU
// 2025-05-05
include <BOSL2/std.scad>
Layout = "Show"; // [Show,Build,Retainer,Fixture,Washer,Wrench]
Gap = 5; // [0:10]
/* [Hidden] */
HoleWindage = 0.2;
Protrusion = 0.1;
NumSides = 3*3*4;
ID = 0;
OD = 1;
LENGTH = 2;
$fn=3*3*4;
Plate = [16.8,20.0,3.0]; // retainer plate, OD allows for lathe threading
PlateRecessDepth = 1.6;
PlateInnerThick = Plate[LENGTH] - PlateRecessDepth;
ClearID = 11.0;
PinOD = 3.0;
PinOC = 12.0;
WrenchLength = 25.0; // handle on wrench
JawLength = 22.0; // lathe jaw
ThreaderOverrun = 10.0; // stick-out for threading tool clearance
ThreadAllowance = 2*1.0; // clearance for thread depth
//----------
// Define Shapes
module Retainer() {
difference() {
tube(Plate[LENGTH],od=Plate[OD],id=ClearID,anchor=BOTTOM);
up(Plate[LENGTH] + Protrusion)
cyl(PlateRecessDepth + Protrusion,d=Plate[ID],anchor=TOP);
down(Protrusion)
hull()
for (i = [-1,1])
right(i*PinOC/2) down(Protrusion)
cyl(Plate[LENGTH] + Protrusion,d=PinOD,anchor=BOTTOM);
}
}
module Fixture() {
difference() {
regular_prism(6,h=JawLength,d=1.2*Plate[OD],anchor=BOTTOM) position(TOP) {
cyl(PlateRecessDepth + ThreaderOverrun,d=Plate[ID],anchor=BOTTOM);
cyl(Plate[LENGTH] + ThreaderOverrun,d=ClearID,anchor=BOTTOM);
// hull()
for (i = [-1,1])
right(i*PinOC/2)
cyl(Plate[LENGTH] + ThreaderOverrun + Plate[LENGTH]/2,d=PinOD,anchor=BOTTOM);
cyl(ThreaderOverrun,d=Plate[OD] - ThreadAllowance,anchor=BOTTOM);
}
up(JawLength + ThreaderOverrun + Plate[LENGTH] + Protrusion) // M4 burly insert
cyl(10.0 + 5,d=5.5,anchor=TOP);
}
}
module Washer() {
difference() {
tube(Plate[LENGTH],od=Plate[OD] - ThreadAllowance,id=4.5,anchor=BOTTOM);
down(Protrusion)
for (i = [-1,1])
right(i*PinOC/2)
cyl(2*Plate[LENGTH],d=PinOD,anchor=BOTTOM);
}
}
module Wrench() {
difference() {
union() {
cyl(WrenchLength,d=Plate[ID],anchor=BOTTOM);
for (i = [-1,1])
right(i*PinOC/2)
cyl(WrenchLength + Plate[LENGTH],d=PinOD,anchor=BOTTOM);
}
down(Protrusion)
cyl(2*WrenchLength,d=ClearID - 2.0,anchor=BOTTOM);
}
}
//----------
// Build things
if (Layout == "Retainer")
Retainer();
if (Layout == "Fixture")
Fixture();
if (Layout == "Washer")
Washer();
if (Layout == "Wrench")
Wrench();
if (Layout == "Show") {
color("Gold")
Fixture();
up(JawLength + ThreaderOverrun + Gap)
zflip(z=Plate[LENGTH]/2)
Retainer();
color("Green")
up(JawLength + ThreaderOverrun + Plate[LENGTH] + 2*Gap)
Washer();
right(40) {
zflip(z=Plate[LENGTH]/2)
Retainer();
color("Silver")
up(Plate[LENGTH] + Gap)
zflip(z=WrenchLength/2)
Wrench();
}
}
if (Layout == "Build") {
Fixture();
right(1.5*Plate[OD]) {
Retainer();
fwd(1.5*Plate[OD])
Retainer();
}
left(1.5*Plate[OD])
Washer();
fwd(1.5*Plate[OD])
Wrench();
}
@ednisley
Copy link
Author

ednisley commented May 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment