-
Notifications
You must be signed in to change notification settings - Fork 0
/
light-saber.scad
136 lines (115 loc) · 3.65 KB
/
light-saber.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Number of blades
nblades = 5;
// Starting blade bottom radius (mm)
r = 12.6;
// Height of all blades (mm)
h = 120.0;
/* [Advanced] */
// Delta between bottom and top of blade radius (mm)
delta = 1.4;
// Thickness of each blade (mm)
t = 0.8;
// Thickness of the handle (mm)
ht = 3;
// Tolerance between blades (mm)
tolerance = 0.4;
// If the handle should have edges rounded (recommended)
rounded = true;
/* [Use this for preview] */
// Expand the blades for preview
expand = false;
// Check this to preview how is the inside of the build.
previewInside = false;
// How much expanded blades touch each other when rendering. Use this to preview if they will overlap properly.
bladePreviewOffset = 20;
module blade(height, r1, r2, thickness, fillTop=false) {
$fn=60;
echo("Creating blade with", height, r1, r2, thickness, fillTop);
difference() {
cylinder(h=height, r1=r1, r2=r2);
translate([0, 0, -1])
cylinder(h=height+2, r1=r1-thickness, r2=r2-thickness);
}
if(fillTop) {
translate([0, 0, h-thickness])
cylinder(h=thickness, r1=r2, r2=r2);
}
}
module handle() {
$fn=40;
height = rounded ? h-1 : h;
r1 = r + ht;
r2 = r1-delta;
color("gray")
translate([0, 0, rounded ? 0.5 : 0])
difference() {
minkowski() {
union() {
// Base
cylinder(height, r1, r1);
// Bottom
translate([0, 0, 4]) cylinder(5, r1, r1+4);
translate([0, 0, 9]) cylinder(5, r1+4, r1+3);
translate([0, 0, 14]) cylinder(3, r1+3, r1);
// Middle
for(i=[0: 6: 32]) {
translate([0, 0, height-30-i]) cylinder(3, r1+2, r1);
translate([0, 0, height-33-i]) cylinder(3, r1, r1+2);
}
difference() {
translate([r-4, -5, 35]) cube([8, 10, 20]);
translate([r+4, -5, 50])
rotate([0, -45, 0])
cube([8, 10, 20]);
}
// Top
translate([0, 0, height- 5.0]) cylinder(5, r1+4, r1+4);
translate([0, 0, height- 8.0]) cylinder(3, r1+2, r1+4);
translate([0, 0, height-14.0]) cylinder(6, r1+2, r1+2);
translate([0, 0, height-16.0]) cylinder(2, r1, r1+2);
}
if (rounded) {
sphere(0.5, $fn=12);
}
}
translate([0, 0, -1])
cylinder(height+2, r1-ht+tolerance+1, r2-ht+tolerance+1);
}
}
module handleLid(r) {
r1 = r + ht;
color("gray")
translate([expand ? 0 : 4*r, 0, 0])
difference() {
cylinder(8, r1+2.5, r1+2.9);
translate([0, 0, 1.1])
cylinder(7, r1+0.8, r1+0.8);
}
}
function m(n) = expand ? (n<0 ? 0 : n) : 0;
module rotateToPrint() {
vec = expand ? [0, 0, 0] : [180, 0, 0];
off = expand ? [0, 0, 0] : [0, 0, -h];
rotate(vec) translate(off) children();
}
difference() {
union() {
rotateToPrint()
handle();
// Blades
rotateToPrint()
for (i = [0 : nblades-1]) {
let (r1 = r-(i*delta)-(i*tolerance), r2 = r1-delta) {
translate([0, 0, m(i+1)*(h - bladePreviewOffset)])
color("lightgreen")
blade(h, r1, r2, t, (i==nblades-1? true : false) );
}
}
handleLid(r);
}
// Cut in half to see the internals
if (previewInside) {
translate([0, -100, -1])
cube([200, 200, (nblades+2)*h]);
}
}