-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbell.scad
555 lines (441 loc) · 18.7 KB
/
bell.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
//DO NOT RUN THIS SCRIPT, IT WILL GENERATE ERRORS!
//instead open one of the models in the sub-folders, for example large_tenor. This script will be called from there
//curve library to generate the neckpipe. Not ideal, but works for now and much easier
//to create good tubes with than with sweep() like the tuning slide.
//TODO: replace with the library newly written for this project, bent_tubes :)
use <Curved_Pipe_Library_for_OpenSCAD/curvedPipe.scad>;
use <bessel.scad>;
use <connections.scad>;
include <tuning_slide.scad>;
//the curve (not really a polygon, just a set of points for now!) of the bell
bell_profile = create_bell_profile(bell_input, steps);
//ECHO THE BELL PROFILE
//for(t= [0:len(bell_profile)-1]) {
// echo(str(2790+bell_profile[t][1],",",bell_profile[t][0]*2,";"));
//}
//the height of the bell minus tuning slide receiver length
//TODO: get rid of the 'minus tuning slide receiver length?
total_bell_height = -sum_length(bell_input, 0);
neckpipe_cut_height_calculated = total_bell_height + neck_pipe_length - neckpipe_cut_height;
echo(top_neckpipe_bell_connection_height - neckpipe_cut_height_calculated, "test");
top_neckpipe_bell_connection_height=neckpipe_cut_height_calculated-neckpipe_bell_connection_radius;
neckpipe_bell_connection_height = top_neckpipe_bell_connection_height+neckpipe_cut_height;
echo(neckpipe_bell_connection_height);
echo("total bell height", total_bell_height);
rotate([180,0,0]) {
//temporary render for a test
//translate([0,0,400])
if(part == "tube_connector_test_top") {
render_bell_segment(render_bottom_lip=true, render_top_lip=false, min_height=-410, max_height=-400);
}
if(part == "tube_connector_test_bottom") {
render_bell_segment(render_bottom_lip=false, render_top_lip=true, min_height=-400, max_height=-380);
}
if(part == "slide_receiver_test") {
slide_receiver(neckpipe_wall_thickness);
}
if(part == "tuning_slide_test_one") {
tuning_slide_test_one();
}
if(part == "tuning_slide_test_two") {
tuning_slide_test_two();
}
if(part == "connection_test_one") {
}
if(part == "connection_test_two") {
}
//solid_bell();
//three part bell section render
if(part == "all" || part == "bell_top") {
union() {
render_bell_segment(render_bottom_lip=true, render_top_lip=false, min_height=third_bell_cut, max_height=second_bell_cut);
upper_bell_connection_base();
}
}
if(part == "all" || part == "bell_middle") {
render_bell_segment(render_bottom_lip=true, render_top_lip=true, min_height=second_bell_cut, max_height=first_bell_cut,render_flat_bottom_lip=false);
lower_bell_connection_base();
}
if(part == "all" || part == "bell_bottom_1") {
intersection() {
render_bell_bottom(two_part_cut_height);
translate([-120+210,-120,-200])
cube([210, 250, 200]);
}
}
if(render_bell_flare_in_two_pieces) {
if(part == "all" || part == "bell_bottom") {
intersection() {
render_bell_bottom(two_part_cut_height);
translate([-120,-120,-200])
cube([210, 250, 200]);
}
}
if(part == "all" || part == "bell_bottom_top_part") {
intersection() {
render_bell_segment(render_bottom_lip=false, render_top_lip=true, min_height=first_bell_cut, max_height=two_part_cut_height,render_flat_bottom_lip=true);
translate([-120,-120,-200])
cube([210, 250, 200]);
}
}
} else {
if(part == "all" || part == "bell_bottom") {
if(bell_bottom_fits_on_plate) {
render_bell_segment(render_bottom_lip=false, render_top_lip=true, min_height=first_bell_cut, max_height=0);
if(render_bell_support) {
bell_support();
}
} else {
intersection() {
render_bell_segment(render_bottom_lip=false, render_top_lip=true, min_height=first_bell_cut, max_height=0);
translate([-120,-120,-200])
cube([210, 250, 200]);
}
if(render_bell_support) {
bell_support();
}
}
}
}
if(part == "all") {
translated_tuning_slide();
}
if(part == "tuning_slide") {
tuning_slide( $fn = tuning_slide_fn);
}
//#check_slide_clearance(neckpipe_wall_thickness);
if(part == "all" || part == "neckpipe_bottom") {
bottom_part_of_neckpipe(neckpipe_wall_thickness);
if(render_neckpipe_bell_connection_with_neckpipe) {
bell_side_neckpipe_bell_connection();
}
}
if(part == "all" || part == "neckpipe_top") {
top_part_of_neckpipe(neckpipe_wall_thickness);
if(render_neckpipe_bell_connection_with_neckpipe) {
tuning_slide_side_neckpipe_bell_connection();
}
}
if(part == "neckpipe") {
rotate([-90,0,0]) {
neckpipe(neckpipe_wall_thickness);
bell_side_neckpipe_bell_connection();
tuning_slide_side_neckpipe_bell_connection();
}
}
if(part == "test_1") {
intersection() {
translate([0, 500,-150])
rotate([-90,0,0]) {
top_part_of_neckpipe(neckpipe_wall_thickness);
};
translate([-50,12,-75])
cube(100);
}
}
if(part == "test_2") {
intersection() {
bell_side_neckpipe_bell_connection();
translate([-50,-220,-375])
cube(100);
}
}
if(!render_neckpipe_bell_connection_with_neckpipe) {
if(part == "all" || part == "connection_bottom") {
bell_side_neckpipe_bell_connection();
}
if(part == "all" || part == "connection_top") {
tuning_slide_side_neckpipe_bell_connection();
}
}
}
module render_bell_bottom(height) {
union() {
render_bell_segment(render_bottom_lip=false, render_top_lip=false, min_height=height, max_height=0);
}
}
module tuning_slide_test_one() {
//print only the small tuning slide peg thing
intersection() {
tuning_slide($fn=tuning_slide_fn);
translate([-50,-100,0])
cube(100);
}
}
module tuning_slide_test_two() {
intersection() {
small_tuning_slide_sleeve(neckpipe_wall_thickness);
translate([-200,-200,-1050])
cube(500);
}
}
module check_slide_clearance(wall_thickness) {
neckpipe_implementation(wall_thickness,
neck_pipe_radius,
false, check_slide_clearance=true);
}
module translated_tuning_slide() {
translate([0,-tuning_slide_radius, total_bell_height]) {//total_bell_height-tuning_slide_small_length]) {
rotate([270,0,0]) {
tuning_slide($fn=tuning_slide_fn);
}
};
}
module slide_receiver(wall_thickness, solid = false) {
if(!solid) {
difference() {
cylinder(r2=slide_receiver_large_radius + wall_thickness, r1=slide_receiver_small_radius +wall_thickness, h=slide_receiver_length);
cylinder(r2=slide_receiver_large_radius, r1=slide_receiver_small_radius, h=slide_receiver_length);
};
} else {
cylinder(r2=slide_receiver_large_radius + wall_thickness, r1=slide_receiver_small_radius +wall_thickness, h=slide_receiver_length);
}
edge_for_locknut_length= 2.5;
outer_edge_for_locknut_length = solid ? edge_for_locknut_length +10: edge_for_locknut_length;
edge_for_locknut_thickness = 1.5;
translate([0,0,slide_receiver_length-edge_for_locknut_length])
difference() {
cylinder(r=slide_receiver_large_radius + wall_thickness+edge_for_locknut_thickness, h=outer_edge_for_locknut_length);
cylinder(r=slide_receiver_large_radius + wall_thickness, h=edge_for_locknut_length);
}
if(solid) {
}
if(!solid) {
//sleeve to make a good connection to the neckpipe - which could be less wide than this!
translate([0,0,-slide_receiver_sleeve_length])
difference() {
cylinder(r2=slide_receiver_small_radius + wall_thickness, r1=neck_pipe_radius+wall_thickness, h=slide_receiver_sleeve_length);
cylinder(r2=slide_receiver_small_radius, r1=neck_pipe_radius, h=slide_receiver_sleeve_length);
}
} else {
//sleeve to make a good connection to the neckpipe - which could be less wide than this!
translate([0,0,-slide_receiver_sleeve_length])
cylinder(r2=slide_receiver_small_radius + wall_thickness, r1=neck_pipe_radius+wall_thickness, h=slide_receiver_sleeve_length);
}
}
module bell_side_neckpipe_bell_connection() {
neckpipe_bell_connection(neckpipe_bell_connection_height);
}
module tuning_slide_side_neckpipe_bell_connection() {
neckpipe_bell_connection(top_neckpipe_bell_connection_height);
}
module neckpipe_bell_connection(height) {
difference() {
translate([0,0,height])
rotate([90,0,0])
cylinder(h = tuning_slide_radius*2, r=neckpipe_bell_connection_radius);
solid_neckpipe(neckpipe_wall_thickness);
solid_bell_segment(height-30, height+30);
bell_connection_bases(connection_base_clearance, difference_with_bell=false);//speed up rendering by making this part very simple
if(!render_neckpipe_bell_connection_with_neckpipe) {
neckpipe_connection_bases(connection_base_clearance);
}
}
}
module bottom_part_of_neckpipe(wall_thickness) {
intersection() {
translate([-50, -tuning_slide_radius*2-50, neckpipe_cut_height_calculated])
cube(neckpipe_cut_height);
neckpipe(wall_thickness);
}
translate([0, -tuning_slide_radius*2, neckpipe_cut_height_calculated])
rotate_extrude()
top_joint([[neck_pipe_radius,0], [neck_pipe_radius, 10]], rotate=true);
}
module top_part_of_neckpipe(wall_thickness) {
intersection() {
translate([-50, -tuning_slide_radius*2-50, neckpipe_cut_height_calculated-neckpipe_cut_height])
cube(neckpipe_cut_height);
neckpipe(wall_thickness);
}
bottom_joint_height=10;
translate([0, -tuning_slide_radius*2, neckpipe_cut_height_calculated -bottom_joint_height])
rotate_extrude()
bottom_joint([[neck_pipe_radius,0], [neck_pipe_radius, 10]], rotate=true, joint_clearance,solid=false);
}
module neckpipe(wall_thickness) {
neckpipe_implementation(wall_thickness,
neck_pipe_radius,
false);
neckpipe_connection_bases();
//TODO: slide locknut
//TODO: split in separate parts so it can be printed
}
//a solid neckpipe. useful in difference with some other things
module solid_neckpipe(wall_thickness) {
neckpipe_implementation(wall_thickness, neck_pipe_radius, solid=true);
bottom_joint([[neck_pipe_radius,0], [neck_pipe_radius, 10]], rotate=true, joint_clearance, solid=true);
connection_bases();
bottom_joint_height=10;
translate([0, -tuning_slide_radius*2, neckpipe_cut_height_calculated -bottom_joint_height])
rotate_extrude()
bottom_joint([[neck_pipe_radius,0], [neck_pipe_radius, 10]], rotate=true, joint_clearance, solid=true);
}
module neckpipe_implementation(wall_thickness, neck_pipe_radius, solid=false, check_slide_clearance=false) {
small_tuning_slide_sleeve(neckpipe_wall_thickness, solid);
od = neck_pipe_radius*2 + wall_thickness+2;
id = solid? 0.0005 : neck_pipe_radius*2;
goose_neck_offset = 4;
goose_neck_start = 75;
slide_receiver_begin = neck_pipe_minus_tuning_slide_receiver_length -slide_receiver_length;
goose_neck_x_length = slide_receiver_begin - goose_neck_start;
goose_neck_y_length = goose_neck_offset;
goose_neck_angle=atan(goose_neck_y_length/goose_neck_x_length);
//neck pipe, including gooseneck
//LOOK HERE
translate([0, -tuning_slide_radius *2, total_bell_height + tuning_slide_small_length + tuning_sleeve_extra_length])
curvedPipe([ [0,0,0],
[0,0,goose_neck_start],
[0,-goose_neck_offset,slide_receiver_begin]
],
2, //two segments. strange library
[50],
od,
id);
//slide receiver
translate([0, -tuning_slide_radius *2-goose_neck_offset, total_bell_height + tuning_slide_small_length+ tuning_sleeve_extra_length + slide_receiver_begin])
rotate([goose_neck_angle, 0, 0])
slide_receiver(wall_thickness, solid);
if(check_slide_clearance) {
translate([0, -tuning_slide_radius *2-goose_neck_offset, total_bell_height + tuning_slide_small_length + tuning_sleeve_extra_length + slide_receiver_begin])
rotate([goose_neck_angle, 0, 0])
cylinder(r=5, h=730);
}
}
module connection_bases(clearance=0.0) {
neckpipe_connection_bases(clearance);
bell_connection_bases(clearance);
}
module neckpipe_connection_bases(clearance=0.0) {
if(!render_neckpipe_bell_connection_with_neckpipe) {
neckpipe_connection_base(19, top_neckpipe_bell_connection_height, clearance);
neckpipe_connection_base(16, neckpipe_bell_connection_height, clearance);
}
}
module neckpipe_connection_base(translation, height, clearance) {
difference() {
translate([0,-tuning_slide_radius*2+translation, height-3])
rotate([70,0,0])
scale([1,1,1])
cylinder(r2=6.3+clearance, r1=3+clearance, h=19, $fn=8);
neckpipe_implementation(neckpipe_wall_thickness, neck_pipe_radius, true);
}
}
module bell_connection_bases(clearance=0.0, difference_with_bell=true) {
upper_bell_connection_base(clearance, difference_with_bell);
lower_bell_connection_base(clearance, difference_with_bell);
}
module upper_bell_connection_base(clearance=0.0, difference_with_bell=true) {
bell_connection_base(top_neckpipe_bell_connection_height, clearance, difference_with_bell);
}
module lower_bell_connection_base(clearance=0.0, difference_with_bell=true) {
bell_connection_base(neckpipe_bell_connection_height, clearance, difference_with_bell);
}
module bell_connection_base(height, clearance, difference_with_bell=true) {
cylinder_height=15;
difference() {
translate([0, -radius_at_height(bell_profile, height-4)-cylinder_height+5, height])
rotate([-70,0,0])
scale([1,1,1])
cylinder(r2=8+clearance, r1=1+clearance, h=cylinder_height, $fn=4);
// solid_bell();
if(difference_with_bell) {
solid_bell_segment(height-cylinder_height/2, height+cylinder_height);
}
}
}
module small_tuning_slide_sleeve(wall_thickness, solid=false) {
translate([0, -tuning_slide_radius *2, total_bell_height])
difference() {
cylinder(h = tuning_slide_small_length + tuning_sleeve_extra_length, r = tuning_slide_small_radius + tuning_slide_wall_thickness + tuning_slide_spacing + wall_thickness);
if(!solid) {
cylinder(h = tuning_slide_small_length + tuning_sleeve_extra_length, r = tuning_slide_small_radius + tuning_slide_wall_thickness + tuning_slide_spacing);
}
};
translate([0, -tuning_slide_radius *2, total_bell_height+tuning_slide_small_length])
difference() {
cylinder(h=20, r2=neck_pipe_radius+wall_thickness, r1=tuning_slide_small_radius + +tuning_slide_wall_thickness + tuning_slide_spacing + wall_thickness);
if(!solid) {
cylinder(h=20, r=neck_pipe_radius);
}
}
}
module solid_small_tuning_slide_sleeve(wall_thickness) {
small_tuning_slide_sleeve(wall_thickness, solid=true);
}
module render_bell_segment(render_bottom_lip, render_top_lip, min_height, max_height, render_flat_bottom_lip=false) {
polygon = cut_curve(bell_profile, min_height, max_height);
echo("start and end of polygon: " );
echo(polygon[0]);
echo(polygon[len(polygon)-1]);
rotate_extrude()
union() {
extrude_line(polygon, bell_wall_thickness, solid=false);
if(render_top_lip) {
top_joint(polygon, joint_clearance);
};
if(render_bottom_lip) {
bottom_joint(polygon, joint_clearance);
}
if (render_flat_bottom_lip) {
flat_bottom_joint(bell_profile, min_height, max_height, bell_wall_thickness, joint_clearance);
}
}
}
module solid_bell() {
rotate_extrude()
solid_bell_profile();
}
module solid_bell_profile() {
extrude_line(bell_profile, bell_wall_thickness, solid=true);
}
module solid_bell_segment(min_height, max_height) {
polygon = cut_curve(bell_profile, min_height, max_height);
rotate_extrude()
extrude_line(polygon, bell_wall_thickness, solid=true);
}
//custom support rendering for bell bottom
use <scad-utils/lists.scad>;
//a partial circle, from begin to end. 0 to 1 means a full circle
function circle_points(r, begin, end) = [
for (i=[0:$fn])
let (a=begin + i*(end-begin)/$fn)
r * [cos(a*360), sin(a*360)]
];
support_thickness=0.42;
function zigzag(outer_radius, inner_radius, extra=0, step=0.02) = flatten(
[for(i=[0:step:1])
concat(
circle_points(outer_radius, i+extra, i+step/2-extra, $fn=1),
circle_points(inner_radius, i+step/2-extra, i+step+extra, $fn=1)
)
]
);
//polygon(test);
smaller_bell_profile = concat([for(i=[0:len(bell_profile)]) bell_profile[i] + [0,0.1]],
bell_profile[len(bell_profile)-1] //include the first 0.1mm as well :)
);
module smaller_solid_bell_segment(smaller_bell_profile, min_height, max_height) {
// polygon = cut_curve(smaller_bell_profile, min_height, max_height);
rotate_extrude()
extrude_line(smaller_bell_profile, 0, solid=true);//0 means no wall thickness - it's the inside profile we want here
}
// rotate([0,180, 0])
//smaller_solid_bell_segment(smaller_bell_profile, -900, 100);
module bell_support_part(outer_radius, inner_radius, step) {
intersection() {
rotate([0,180,0])
linear_extrude(height=50) {
polygon(concat(zigzag(outer_radius, inner_radius, 0, step),
zigzag(outer_radius-support_thickness,
inner_radius - support_thickness,
support_thickness/(outer_radius*2*PI),
step)));
}
smaller_solid_bell_segment(smaller_bell_profile, -900, 100);
}
}
module bell_support() {
bell_support_part(bell_radius, bell_radius-15, step=0.015);
bell_support_part(bell_radius-15-0.5, bell_radius-30, step=0.02);
}