forked from nophead/NopSCADlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.scad
146 lines (127 loc) · 5.16 KB
/
module.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
137
138
139
140
141
142
143
144
145
146
//
// NopSCADlib Copyright Chris Palmer 2018
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Random screw down modules. Currently just DROK buck converters.
//
include <../core.scad>
function mod_part(type) = type[1]; //! Description
function mod_length(type) = type[2]; //! Body length
function mod_width(type) = type[3]; //! Body width
function mod_height(type) = type[4]; //! Body height
function mod_screw(type) = type[5]; //! Screw type
function mod_screw_z(type)= type[6]; //! Thickness of screw lug
function mod_hole_r(type) = type[7] / 2; //! Screw hole radius
function mod_holes(type) = type[8]; //! Screw hole positions
module mod(type) { //! Draw specified module
vitamin(str("mod(", type[0], "): ", mod_part(type)));
module drok_buck() {
l = mod_length(type);
w = mod_width(type);
h = mod_height(type);
body_l = 31;
end_t = 1.5;
chamfer = 2;
lug_l = (l - body_l) / 2 - end_t;
lug_w = 19;
lug_w2 = 10;
lug_t = 2;
lug_r = 2.5;
hole_r = mod_hole_r(type);
vane_t = 1;
vane_h = 5;
vane_l = 7;
vane_p = 10;
boss_od = 7.5;
boss_id = 5;
boss_h = 2.3;
boss_chamfer = 1;
module profile()
hull() {
translate([-w / 2, 0])
square([w, h - chamfer]);
translate([-w / 2 + chamfer, 0])
square([w - 2 * chamfer, h]);
}
module lug()
difference() {
hull() {
for(side = [-1, 1])
translate([side * lug_w2 / 2, lug_l - lug_r])
circle(lug_r);
translate([-lug_w / 2, -1])
square([lug_w, 1]);
}
hull()
for(y = [hole_r, 100])
translate([0, y])
circle(hole_r);
}
color("silver")
rotate([90, 0, 90])
linear_extrude(height = body_l, center = true)
profile();
color(grey20)
for(end = [-1, 1])
translate([end * body_l / 2, 0, 0])
rotate([90, 0, end * 90])
union() {
linear_extrude(height = end_t) // endcap
profile();
translate_z(end_t)
rotate([90, 0, 180])
linear_extrude(height = lug_t) // lug
lug();
for(side = [-1, 1]) {
translate([side * vane_p / 2, lug_t, end_t]) // buttress vanes
rotate([0, -90, 0])
linear_extrude(height = vane_t, center = true)
polygon([[0, 0], [0, vane_h - lug_t], [vane_l, 0]]);
translate([side * vane_p / 2, h / 2, end_t]) // bosses
rotate_extrude()
difference() {
hull() {
square([boss_od / 2,boss_h - boss_chamfer]);
square([boss_od / 2 - boss_chamfer, boss_h]);
}
translate([0, boss_h - boss_chamfer])
square([boss_id / 2, boss_h]);
}
}
}
}
drok_buck();
}
module mod_screw_positions(type) //! Position children at the screw positions
for(p = mod_holes(type))
translate([p.x, p.y])
children();
module module_assembly(type, thickness) { //! Module with its fasteners in place
screw = mod_screw(type);
washer = screw_washer(screw);
nut = screw_nut(screw);
screw_length = screw_longer_than(thickness + mod_screw_z(type) + 2 * washer_thickness(washer) + nut_thickness(nut, true));
mod(type);
mod_screw_positions(type) {
translate_z(mod_screw_z(type))
nut_and_washer(nut, true);
translate_z(-thickness)
vflip()
screw_and_washer(screw, screw_length);
}
}