-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbatteryholder.scad
95 lines (83 loc) · 3.33 KB
/
batteryholder.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Steven Kramer 2018
// stevanov/ParametricBatteryStore is licensed under the
// GNU Affero General Public License v3.0
//********************************************************
//Change the following parameters according to your liking
//********************************************************
//cylinder paramters; the item you want to store
cylDiameter = 14.5; //cylinder diameter; 14.5 for typical AA 10.5 for AAA
cylSlack = 0.5; //wiggle room around cylinder, 0.5 seems to be okay
cylEnclosedHeight = 23; //amount of the battery that sits in the enclore, about 50% is good
cylWall = 0.8; //minimum thickness of the plastic wall between objects, let this be a multiple of your 3d printers nozzle
nippleHeight = 1; //depth of the indent in the bottom of the holder for the nipple/positive terminal of the battery to sit in
//container paramters; the box the stored item sits in
xSlots = 3; //
ySlots = 5; //
contBottom = 1; //multiple of printer layer height
contWall = 0.8; //multiple of printer nozzle width
//********************************************************
//global variables, no need to touch these unless you want to
//********************************************************
$fn = 44; //works best if modulo 4, since cylinders touch on 4 sides, 24 seems okay
cylTotal = cylDiameter+cylSlack+cylWall;
containerX = cylTotal*xSlots;
containerY = cylTotal*ySlots;
//********************************************************
//functions below, no need to touch these unless you want to
//********************************************************
difference(){
container("round"); //available types; square,round,light
slots();
}
module container(type)
{
if (type == "square") {
linear_extrude(cylEnclosedHeight+contBottom+nippleHeight)
{
offset(r = contWall){
square(size=[containerX-cylWall,containerY-cylWall],center=true);
}
}
} else if (type == "round" || type == "light") {
union()
{
translate([-(containerX/2)+(cylTotal/2), -(containerY/2)+(cylTotal/2)])
{
for (i = [0 : cylTotal : cylTotal*ySlots-1])
{
translate([0,i,0])
for (i = [0 : cylTotal : cylTotal*xSlots-1])
{
translate([i,0,0])
cylinder(d=cylTotal+contWall,h=cylEnclosedHeight+contBottom+nippleHeight);
}
}
}
if (type == "round")
{
linear_extrude(cylEnclosedHeight+contBottom+nippleHeight)
{
square(size=[containerX-cylTotal,containerY-cylTotal],center=true);
}
}
}
} else if (type == "") {
}
}
module slots()
{
translate([-(containerX/2)+(cylTotal/2), -(containerY/2)+(cylTotal/2)])
{
for (i = [0 : cylTotal : cylTotal*ySlots-1])
{
translate([0,i,0])
for (i = [0 : cylTotal : cylTotal*xSlots-1])
{
translate([i,0,contBottom+nippleHeight])
cylinder(d=cylTotal-cylWall,h=cylEnclosedHeight+1); //+1 is only to make preview less glitchy
translate([i,0,contBottom])
cylinder(d=(cylTotal-cylWall)/2,h=nippleHeight+1); //+1 is only to make preview less glitchy
}
}
}
}