-
Notifications
You must be signed in to change notification settings - Fork 0
/
bracket.scad
102 lines (91 loc) · 3.97 KB
/
bracket.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
use <brick.scad>;
module bracket(
angle=90,
base_stud_length=2,
base_stud_width=2,
overhang_stud_length=2,
overhang_stud_width=2,
stud_rescale=1 ) {
// Values from brick.scad.
brick_height = 9.6; // Height of the non-stud portion of a regular brick.
stud_spacing=8; // Distance between centers of studs.
stud_diameter=4.85; // Diameters of studs.
wall_play=0.1; // Amount of space removed from the outer edge of bricks so that they will fit next to each other.
base_height = brick_height/3;
base_width = (base_stud_width * stud_spacing) - (wall_play * 2);
base_length = (base_stud_length * stud_spacing) - (wall_play * 2);
overhang_height = brick_height/3;
overhang_width = (overhang_stud_width * stud_spacing) - (wall_play * 2);
overhang_length = (overhang_stud_length * stud_spacing) - (wall_play * 2);
if (base_stud_length > base_stud_width) {
// brick.scad always makes the longest number the length. Rotate it manually if we want it wider than long.
rotate([0, 0, 90])
block(
height=.33333333333,
type="brick",
length=base_stud_length,
width=base_stud_width,
stud_rescale=stud_rescale
);
}
else {
block(
height=.33333333333,
type="brick",
length=base_stud_length,
width=base_stud_width,
stud_rescale=stud_rescale
);
}
if (angle <= 90 ) {
// Add a solid section protruding out one end of the base to join it to the angled portion.
translate([((base_width+overhang_height*sin(angle))/2)+wall_play/2, 0, base_height/2])
cube([(overhang_height*sin(angle))+wall_play, base_length,base_height], true);
}
difference() {
translate( [base_width/2 + (overhang_height*sin(angle))+wall_play, 0, base_height] )
rotate([0, angle, 0])
translate([overhang_width/2, 0, -overhang_height])
union() {
if (overhang_stud_length > overhang_stud_width) {
// brick.scad always makes the longest number the length. Rotate it manually if we want it wider than long.
rotate([0, 0, 90])
block(
height=.33333333333,
type="brick",
length=overhang_stud_length,
width=overhang_stud_width,
stud_type="hollow",
stud_rescale=stud_rescale
);
}
else {
block(
height=.33333333333,
type="brick",
length=overhang_stud_length,
width=overhang_stud_width,
stud_type="hollow",
stud_rescale=stud_rescale
);
}
// Fill in the underside of the angled portion. type=baseplate would do this, but it would also make it thinner and give it rounded edges.
translate( [0, 0, overhang_height/2] ) cube( [overhang_width, overhang_length, overhang_height], true );
}
// Remove from the angled brick everything above the top of the base brick.
translate([ 0, 0, base_height + overhang_width/2]) {
cube( [ base_width + (overhang_height * 2 * sin(angle)) + 0.01, max(base_length, overhang_length)+0.01, overhang_width ], true);
}
// Remove from the angle brick everything past the edge of the base.
translate( [0, 0, base_height/2] ) {
cube( [ base_width, max(base_length, overhang_length)+0.01, base_height * 10 ], true);
}
}
}
bracket(
angle=90,
base_stud_length=2,
base_stud_width=2,
overhang_stud_length=4,
overhang_stud_width=2,
stud_rescale=1.025);