-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtop.scad
71 lines (55 loc) · 1.5 KB
/
top.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
include <nuts_and_bolts.scad>
/**
* Size of the bolts
*/
boltSize=4;
boltTolerance=0.2;
boltFlesh=3;
bottomHeight = boltSize + boltTolerance + boltFlesh + METRIC_NUT_THICKNESS[boltSize] + boltTolerance;
wallThickness=2;
$fn=100;
/**
* Top configurations
*/
topConfigurations = [
[10, 24.5], // normal vallejo top
[10, 35], // vallejo big top
[10,32], // games workshop
[10,36,6] // games workshop old
];
/**
* Module for creating a top
*/
module top(height, dia, fn=100) {
union() {
difference() {
cylinder(d=dia+2*wallThickness, h=bottomHeight, center=false);
translate([0, 0, bottomHeight - boltSize - boltTolerance]) {
rotate([0, 180, 0]) {
#boltHole(size=boltSize,length=bottomHeight, tolerance=boltTolerance);
}
}
nutHole(size=boltSize,tolerance=boltTolerance);
}
translate([0, 0, bottomHeight]) {
difference() {
cylinder(d=dia+2*wallThickness, h=height, center=false);
cylinder(d=dia, h=height, center=false,$fn=fn);
}
}
}
}
/**
* Iterate over the tops and draw them
*/
for(idx = [0:len(topConfigurations)-1]) {
xOffset = sumv(topConfigurations,idx,0);
translate([xOffset,0,0]) {
fn = (len(topConfigurations[idx]) == 2) ? 100 : topConfigurations[idx][2];
top(height = topConfigurations[idx][0], dia = topConfigurations[idx][1], fn = fn);
}
}
/**
* Used to calculate the sum of all dias from to
*/
function sumv(v,i,s=0) = (i==s ? v[i][1]+10 : v[i][1]+10 + sumv(v,i-1,s));