-
Notifications
You must be signed in to change notification settings - Fork 1
/
customizable_straight_beam_v4o.scad
168 lines (145 loc) · 5.32 KB
/
customizable_straight_beam_v4o.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
Even More Customizable Straight LEGO Technic Beam
Based on Customizable Straight LEGO Technic Beam
and Parametric LEGO Technic Beam by "projunk" and "stevemedwin"
www.thingiverse.com/thing:203935
Also uploaded to Prusaprinters.org at https://www.prusaprinters.org/prints/33038-even-more-customizable-straight-beam-for-legotm-te
Modified by Sam Kass
November 2015
Modified by Orso Eric (2024-03)
https://github.com/OrsoEric/OpenSCAD-lego-library
2024-08-03
added user margin, the plates printed horizontally could need more margin than plates printed vertically
increased base tollerance of round hole
fine tune indent and hole size
2024-08-04 there is an asymmetry in the hole, the oPo shows there should be a thin bodred above the hole
*/
// user parameters
//Hole sequence
//o for round hole
//+ for plus-shaped hole
//capital O for sideways hole
//capital P for sideways plus
//and x for blank spot.
//eg. lego_beam("+xPOo");
cn_lego_pitch_stud = 8.0;
cn_lego_drill_small = 4.7+0.4;
cn_lego_drill_large = 5.9+0.5;
cn_lego_height_beam = 7.8;
cn_lego_width_beam = 7.3;
cn_lego_drill_axel = 2.0+0.05;
//How deep the shriking of the big hole
cn_lego_drill_depth_indent = 0.5;
//How steep the transition from big hole to small hole
cn_lego_drill_sharpness = 0.5;
module body( in_length_stud, in_height = cn_lego_height_beam, in_precision = 0.5 )
{
translate([0, cn_lego_width_beam/2, 0])
hull()
{
cylinder(r=cn_lego_width_beam/2, h=in_height,$fa = 0.1+in_precision, $fs = 0.1+in_precision/2);
translate([(in_length_stud-1)*cn_lego_pitch_stud, 0, 0])
cylinder(r=cn_lego_width_beam/2, h=in_height,$fa = 0.1+in_precision, $fs = 0.1+in_precision/2);
}
}
module hole( in_height = cn_lego_height_beam, in_precision = 0.5, in_margin = 0.0 )
{
an_cross_section = [
//Bottom
[0,0],
//Top
[0,in_height],
//Top Big hole
[(cn_lego_drill_large+in_margin)/2,in_height],
[(cn_lego_drill_large+in_margin)/2,in_height-cn_lego_drill_depth_indent],
//Top Small Hole
[(cn_lego_drill_small+in_margin)/2,in_height-cn_lego_drill_depth_indent-cn_lego_drill_sharpness],
//Bottom Small hole
[(cn_lego_drill_small+in_margin)/2,cn_lego_drill_depth_indent+cn_lego_drill_sharpness],
//Bottom Big Hole
[(cn_lego_drill_large+in_margin)/2,cn_lego_drill_depth_indent],
[(cn_lego_drill_large+in_margin)/2,0]
];
//Rotate the cross section of the hole around its axis, to generate the hole
rotate_extrude($fa = 0.1+in_precision, $fs = 0.1+in_precision/2)
polygon(an_cross_section);
}
module plus( in_height = cn_lego_height_beam, in_margin = 0.0 )
{
union()
{
translate([-(cn_lego_drill_axel+in_margin)/2, -(cn_lego_drill_small+in_margin)/2, 0])
cube([cn_lego_drill_axel+in_margin, cn_lego_drill_small+in_margin, in_height]);
translate([-(cn_lego_drill_small+in_margin)/2, -(cn_lego_drill_axel+in_margin)/2, 0])
cube([cn_lego_drill_small+in_margin, cn_lego_drill_axel+in_margin, in_height]);
}
}
module lego_beam( is_holes, in_height = cn_lego_height_beam, in_margin = 0.0 )
{
//number of studs
in_length = len(is_holes);
if (in_length > 0)
{
//Center the beam
translate([0,cn_lego_pitch_stud,0])
rotate([90,0,0])
difference()
{
body( in_length, in_height );
for (i = [1:in_length])
{
if (is_holes[i-1] == "+")
translate([(i-1)*cn_lego_pitch_stud, cn_lego_width_beam/2, 0])
plus( in_height, in_margin=in_margin );
else if (is_holes[i-1] == "o")
translate([(i-1)*cn_lego_pitch_stud, cn_lego_width_beam/2, 0])
hole( in_height, in_margin=in_margin );
else if (is_holes[i-1] == "O")
rotate([90,0,0])
translate([(i-1)*cn_lego_pitch_stud, cn_lego_height_beam/2,-cn_lego_pitch_stud+cn_lego_drill_depth_indent/2])
hole( in_height, in_margin=in_margin );
else if (is_holes[i-1] == "P")
rotate([90,0,0])
translate([(i-1)*cn_lego_pitch_stud, cn_lego_height_beam/2,-cn_lego_pitch_stud+cn_lego_drill_depth_indent/2])
plus( in_height, in_margin=in_margin );
else
{
//no drill, leave a blank space
}
}
}
}
}
//Get an array of string, each will become a beam
//E.g. lego_plate(["o+Po", "oPOo", "oP+o"]);
// o+Po
// oPOo
// oP+o
module lego_plate( ias_pattern )
{
//number of beams side to side
in_width_stud = len(ias_pattern);
for (cnt = [0:in_width_stud-1])
{
translate([0,cn_lego_pitch_stud*cnt,-0.5*cn_lego_width_beam])
lego_beam(ias_pattern[cnt], cn_lego_pitch_stud);
}
}
//Same as lego_plate, but slices along width, not length
//It's easier to make patterns on plates this way
//E.g. lego_plate(["ooo", "+PP", "PO+","ooo"]);
module lego_plate_alternate( ias_pattern, in_margin = 0.0 )
{
// number of beams side to side
in_width_stud = len(ias_pattern[0]); // assuming all strings are of the same length
in_length_stud = len(ias_pattern);
echo("Length: ",in_length_stud, "cn_lego_width_beam: ", in_width_stud);
for (cnt = [0:in_width_stud-1])
{
ac_array = [for(i = [0:in_length_stud-1]) ias_pattern[i][cnt]];
echo( "Beam:", cnt, "Pattern:", ac_array );
translate([0,cn_lego_pitch_stud*cnt,-0.5*cn_lego_width_beam])
lego_beam(ac_array, cn_lego_pitch_stud, in_margin=in_margin );
}
}
//lego_plate_alternate(["ooo", "+++", "POP", "ooo"]);