forked from BelfrySCAD/BOSL2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
threading.scad
2316 lines (2250 loc) · 117 KB
/
threading.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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//////////////////////////////////////////////////////////////////////
// LibFile: threading.scad
// Provides generic threading support and specialized support for standard triangular (UTS/ISO) threading,
// trapezoidal threading (ACME), pipe threading, buttress threading, square threading and ball screws.
// Includes:
// include <BOSL2/std.scad>
// include <BOSL2/threading.scad>
// FileGroup: Threaded Parts
// FileSummary: Various types of threaded rods and nuts.
//////////////////////////////////////////////////////////////////////
// Section: Thread Ends and Options
// A standard process for making machine screws is to begin with round stock that has
// beveled ends. This stock is then rolled between flat, grooved plates to form the threads.
// The result is a bolt that looks like this at the end:
// Figure(3D,Med,NoAxes,VPR=[83.7,0,115.5],VPT=[1.37344,1.26411,-0.299415],VPD=35.5861):
// threaded_rod(d=13,pitch=2,l=10,blunt_start=false,$fn=80);
// Figure(2D,Med,NoAxes): A properly mated screw and bolt with beveled ends
// $fn=32;
// projection(cut=true)
// xrot(-90){
// down(2.5)difference(){
// cuboid([20,20,5]);
// zrot(20)
// threaded_rod(d=13.2, pitch=2,l=5.1,blunt_start=false,internal=true);
// }
// up(2.85-2)threaded_rod(d=13, pitch=2, l=10, blunt_start=false);
//
// }
// Continues:
// Cross threading occurs when the bolt is misaligned with the threads in the nut.
// It can destroy the threads, or cause the nut to jam. The standard beveled end process
// makes cross threading a possibility because the beveled partial threads can pass
// each other when the screw enters the nut.
// Figure(2D,Med,NoAxes):
// $fn=32;
// projection(cut=true)
// xrot(-90){
// down(2.5)difference(){
// cuboid([20,20,5]);
// zrot(20)
// threaded_rod(d=13.2, pitch=2,l=5.1,blunt_start=false,internal=true);
// }
// left(.6)up(2.99)yrot(-atan(2/13)-1)rot(180+30)threaded_rod(d=13, pitch=2, l=10, blunt_start=false);
// }
// Continues:
// In addition, those partial screw threads may be weak, and easily broken. They do
// not contribute to the strength of the assembly.
// In 1891 Clinton A. Higbee received a patent for a modification to screw threads
// https://patents.google.com/patent/US447775A meant to address these limitations.
// Instead of beveling the end of the screw, Higbee said to remove the partial thread.
// The resulting screw might look like this:
// Figure(3D,Med,NoAxes,VPR=[72,0,294],VPT=[0,0,0],VPD=44):
// $fn=48;
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,lead_in_shape="cut",end_len=.2);
// Continues:
// Because the threads are complete everywhere, cross threading is unlikely to occur.
// This type of threading has been called "Higbee threads", but in recent machinist
// handbooks it is called "blunt start" threading.
// This style of thread is not commonly used in metal fasteners because it requires
// machining the threads, which is much more costly than the rolling procedure described
// above. However, plastic threads usually have some sort of gradual thread end.
// For models that will be 3D printed, there is no reason to choose the standard
// bevel end bolt, so in this library the blunt start threads are the default.
// If you need standard bevel-end threads, you can choose them with the `blunt_start` options.
// Note that blunt start threads are more efficient.
// .
// Various options exist for controlling the ends of threads. You can specify bevels on threaded rods.
// In conventional threading, bevels are needed on the ends to remove sharp, thin edges, and
// the bevel is sized to the full outer diameter of the threaded rod.
// With blunt start threading, the bevel appears on the unthreaded part of the rod.
// On a threaded rod, a bevel value of `true` or a positive bevel value cut off the corner.
// Figure(3D,Med,NoAxes,VPR=[72,0,54],VPT=[0,0,0],VPD=44):
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,bevel=true,$fn=80);
// Continues:
// A negative bevel value produces a flaring bevel, that might be useful if the rod needs to mate with another part.
// You can also set `bevel="reverse"` to get a flaring bevel of the default size.
// Figure(3D,Med,NoAxes,VPR=[72,0,54],VPT=[0,0,0],VPD=44): Negative bevel on a regular threaded rod.
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,bevel=-2,$fn=80);
// Continues:
// If you set `internal=true` to create a mask for a threaded hole, then bevels are reversed: positive bevels flare outward so that when you subtract
// the threaded rod it gives a beveled edge to the hole. In this case, negative bevels go inward, which might be useful to
// create a bevel at the bottom of a threaded hole.
// Figure(3D,Med,NoAxes,VPR=[72,0,54],VPT=[0,0,0],VPD=44): Threaded rod mask produced using `internal=true` with regular bevel at the top and reversed bevel at the bottom.
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,bevel2=true,bevel1="reverse",internal=true,$fn=80);
// Continues:
// You can also extend the unthreaded section using the `end_len` parameters. A long unthreaded section will make
// it impossible to tilt the bolt and produce misaligned threads, so it could make assembly easier.
// Figure(3D,Med,NoAxes,VPR=[72,0,54],VPT=[0,0,0],VPD=48): Negative bevel on a regular threaded rod.
// threaded_rod(d=13,pitch=2,l=15,end_len2=5,blunt_start=true,bevel=true,$fn=80);
// Continues:
// It is also possible to adjust the length of the lead-in section of threads, or the
// shape of that lead-in section. The lead-in length can be set using the `lead_in` arguments
// to specify a length or the `lead_in_ang` arguments to specify an angle. For general
// threading applications, making the lead in long creates a smaller thread that could
// be more fragile and more prone to cross threading.
// Figure(3D,Med,NoAxes,VPR=[52,0,300],VPT=[0,0,4],VPD=35.5861):
// threaded_rod(d=13,pitch=2,l=10,lead_in=6,blunt_start=true,bevel=false,$fn=80);
// Continues:
// To change the form of the thread end you use the `lead_in_shape` argument.
// You can specify "sqrt", "cut" or "smooth" shapes. The "sqrt" shape is the historical
// shape used in the library. The "cut" shape is available to model Higbee pattern threads, but
// is not as good as the others in practice, because the flat faces on the threads can hit each other.
// The lead-in shape is produced by applying a scale factor to the thread cross section that varies along the lead-in length.
// You can also specify a custom shape
// by giving a function literal, `f(x,L)` where `L` will be the total linear
// length of the lead-in section and `x` will be a value between 0 and 1 giving
// the position in the lead in, with 0 being the tip and 1 being the full height thread.
// The return value must be a 2-vector giving the thread width scale and thread height
// scale at that location. If `x<0` the function must return a thread height scale
// of zero, but it is usually best if the thread width scale does not go to zero,
// because that will give a sharply pointed thread end. If `x>1` the function must
// return `[1,1]`.
// Figure(3D,Med,NoAxes,VPR=[75,0,338],VPT=[-2,0,3.3],VPD=25): The standard lead in shapes
// left_half()zrot(0){
// up(2) threaded_rod(d=13,pitch=2,l=2,blunt_start=true,bevel=false,$fn=128,anchor=BOT);
// up(4) threaded_rod(d=13,pitch=2,l=2.5,blunt_start=true,bevel=false,$fn=128,lead_in_shape="cut",end_len2=.5,anchor=BOT);
// threaded_rod(d=13,pitch=2,l=2,blunt_start=true,bevel=false,$fn=128,lead_in_shape="smooth",anchor=BOT);
// }
// $fn=64;
// s=.85;
// color("black")
// up(3.5)left(4.5)fwd(6)rot($vpr){
// back(1.9)text3d("cut",size=s);
// text3d("sqrt",size=s);
// fwd(1.9)text3d("smooth",size=s);
// }
// Section: Standard (UTS/ISO) Threading
// Module: threaded_rod()
// Synopsis: Creates an UTS/ISO triangular threaded rod.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: threaded_nut()
// Usage:
// threaded_rod(d, l|length, pitch, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a standard ISO (metric) or UTS (English) threaded rod. These threads are close to triangular,
// with a 60 degree thread angle. You can give diameter value which specifies the outer diameter and will produce
// the "basic form" or you can
// set d to a triplet [d_min, d_pitch, d_major] where are parameters determined by the ISO and UTS specifications
// that define clearance sizing for the threading. See screws.scad for how to make screws
// using the specification parameters.
// Arguments:
// d = Outer diameter of threaded rod, or a triplet of [d_min, d_pitch, d_major].
// l / length / h / height = length of threaded rod.
// pitch = Length between threads.
// ---
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default: 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// internal = If true, make this a mask for making internal threads.
// d1 = Bottom outside diameter of threads.
// d2 = Top outside diameter of threads.
// blunt_start = If true apply truncated blunt start threads at both ends. Default: true
// blunt_start1 = If true apply truncated blunt start threads bottom end.
// blunt_start2 = If true apply truncated blunt start threads top end.
// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0
// end_len1 = Specify unthreaded length at the bottom
// end_len2 = Specify unthreaded length at the top
// lead_in = Specify linear length of the lead in section of the threading with blunt start threads
// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads
// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads
// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads
// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads
// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads
// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default"
// teardrop = If true, adds a teardrop profile to the back (Y+) side of the threaded rod, for 3d printability of horizontal holes. If numeric, specifies the proportional extra distance of the teardrop flat top from the screw center, or set to "max" for a pointed teardrop. Default: false
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Example(2D):
// projection(cut=true)
// threaded_rod(d=10, l=15, pitch=1.5, orient=BACK);
// Examples(Med):
// threaded_rod(d=25, height=20, pitch=2, $fa=1, $fs=1);
// threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1);
// threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1, end_len=1.5, bevel=true);
// threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1, blunt_start=false);
// Example(Med;VPR=[100,0,5];VPD=220): Masking a Horizontal Threaded Hole
// difference() {
// cuboid(50);
// threaded_rod(
// d=25, l=51, pitch=4, $fn=36,
// internal=true, bevel=true,
// blunt_start=false,
// teardrop=true, orient=FWD
// );
// }
// Example(Big,NoAxes): Diamond threading where both left-handed and right-handed nuts travel (in the same direction) on the threaded rod:
// $fn=32;
// $slop = 0.075;
// d = 3/8*INCH;
// pitch = 1/16*INCH;
// starts=3;
// xdistribute(19){
// intersection(){
// threaded_rod(l=40, pitch=pitch, d=d,starts=starts,anchor=BOTTOM,end_len=.44);
// threaded_rod(l=40, pitch=pitch, d=d, left_handed=true,starts=starts,anchor=BOTTOM);
// }
// threaded_nut(nutwidth=4.5/8*INCH,id=d,h=3/8*INCH,pitch=pitch,starts=starts,anchor=BOTTOM);
// threaded_nut(nutwidth=4.5/8*INCH,id=d,h=3/8*INCH,pitch=pitch,starts=starts,left_handed=true,anchor=BOTTOM);
// }
function threaded_rod(
d, l, pitch,
left_handed=false,
bevel,bevel1,bevel2,starts=1,
internal=false,
d1, d2, length, h, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
teardrop=false,
anchor, spin, orient
) = no_function("threaded_rod");
module threaded_rod(
d, l, pitch,
left_handed=false,
bevel,bevel1,bevel2,starts=1,
internal=false,
d1, d2, length, h, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
teardrop=false,
anchor, spin, orient
) {
dummy1=
assert(all_positive(pitch))
assert(all_positive(d) || (is_undef(d) && all_positive([d1,d2])));
basic = is_num(d) || is_undef(d) || is_def(d1) || is_def(d2);
dummy2 = assert(basic || is_vector(d,3));
depth = basic ? cos(30) * 5/8
: (d[2] - d[0])/2/pitch;
crestwidth = basic ? 1/8 : 1/2 - (d[2]-d[1])/sqrt(3)/pitch;
profile = [
[-depth/sqrt(3)-crestwidth/2, -depth],
[ -crestwidth/2, 0],
[ crestwidth/2, 0],
[ depth/sqrt(3)+crestwidth/2, -depth]
];
oprofile = internal? [
[-6/16, -depth],
[-1/16, 0],
[-1/32, 0.02],
[ 1/32, 0.02],
[ 1/16, 0],
[ 6/16, -depth]
] : [
[-7/16, -depth*1.07],
[-6/16, -depth],
[-1/16, 0],
[ 1/16, 0],
[ 6/16, -depth],
[ 7/16, -depth*1.07]
];
generic_threaded_rod(
d=basic ? d : d[2], d1=d1, d2=d2, l=l,
pitch=pitch,
profile=profile,starts=starts,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
internal=internal, length=length, height=height, h=h,
blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2,
lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape,
lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2,
end_len=end_len, end_len1=end_len1, end_len2=end_len2,
teardrop=teardrop,
anchor=anchor,
spin=spin,
orient=orient
) children();
}
// Module: threaded_nut()
// Synopsis: Creates an UTS/ISO triangular threaded nut.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: threaded_rod()
// Usage:
// threaded_nut(nutwidth, id, h|height|thickness, pitch,...) [ATTACHMENTS];
// Description:
// Constructs a hex nut or square nut for an ISO (metric) or UTS (English) threaded rod.
// The inner diameter is measured from the bottom of the threads.
// Arguments:
// nutwidth = flat to flat width of nut
// id = inner diameter of threaded hole, measured from bottom of threads
// h / height / l / length / thickness = height/thickness of nut.
// pitch = Distance between threads, or zero for no threads.
// ---
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default: 1
// bevel = if true, bevel the outside of the nut. Default: true for hex nuts, false for square nuts
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 30
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// blunt_start = If true apply truncated blunt start threads at both ends. Default: true
// blunt_start1 = If true apply truncated blunt start threads bottom end.
// blunt_start2 = If true apply truncated blunt start threads top end.
// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0
// end_len1 = Specify unthreaded length at the bottom
// end_len2 = Specify unthreaded length at the top
// lead_in = Specify linear length of the lead in section of the threading with blunt start threads
// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads
// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads
// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads
// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads
// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads
// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default"
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Examples(Med):
// threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25, $slop=0.05, $fa=1, $fs=1);
// threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25, left_handed=true, bevel=false, $slop=0.1, $fa=1, $fs=1);
// threaded_nut(shape="square", nutwidth=16, id=8, h=8, pitch=1.25, $slop=0.1, $fa=1, $fs=1);
// threaded_nut(shape="square", nutwidth=16, id=8, h=8, pitch=1.25, bevel2=true, $slop=0.1, $fa=1, $fs=1);
// rot(90)threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25,blunt_start=false, $slop=0.1, $fa=1, $fs=1);
function threaded_nut(
nutwidth, id, h,
pitch, starts=1, shape="hex", left_handed=false, bevel, bevel1, bevel2, id1,id2,
ibevel1, ibevel2, ibevel, bevang=30, thickness, height,
length, l,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
)=no_function("threaded_nut");
module threaded_nut(
nutwidth, id, h,
pitch, starts=1, shape="hex", left_handed=false, bevel, bevel1, bevel2, id1,id2,
ibevel1, ibevel2, ibevel, bevang=30, thickness, height,
length, l,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
) {
dummy1=
assert(all_nonnegative(pitch), "Nut pitch must be nonnegative")
assert(all_positive(id), "Nut inner diameter must be positive")
assert(all_positive(h),"Nut thickness must be positive");
basic = is_num(id) || is_undef(id) || is_def(id1) || is_def(id2);
dummy2 = assert(basic || is_vector(id,3));
depth = basic ? cos(30) * 5/8
: (id[2] - id[0])/2/pitch;
crestwidth = basic ? 1/8 : 1/2 - (id[2]-id[1])/sqrt(3)/pitch;
profile = [
[-depth/sqrt(3)-crestwidth/2, -depth],
[ -crestwidth/2, 0],
[ crestwidth/2, 0],
[ depth/sqrt(3)+crestwidth/2, -depth]
];
oprofile = [
[-6/16, -depth/pitch],
[-1/16, 0],
[-1/32, 0.02],
[ 1/32, 0.02],
[ 1/16, 0],
[ 6/16, -depth/pitch]
];
generic_threaded_nut(
nutwidth=nutwidth,
id=basic ? id : id[2], id1=id1, id2=id2,
h=h,
pitch=pitch,
profile=profile,starts=starts,shape=shape,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
ibevel1=ibevel1, ibevel2=ibevel2, ibevel=ibevel,
blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2,
lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape,
lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2,
end_len=end_len, end_len1=end_len1, end_len2=end_len2,
l=l,length=length,
anchor=anchor, spin=spin,
orient=orient
) children();
}
// Section: Trapezoidal Threading
// Module: trapezoidal_threaded_rod()
// Synopsis: Creates a trapezoidal threaded rod.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: trapezoidal_threaded_nut()
// Usage:
// trapezoidal_threaded_rod(d, l|length, pitch, [thread_angle=|flank_angle=], [thread_depth=], [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a threaded rod with a symmetric trapezoidal thread. Trapezoidal threads are used for lead screws because
// they are one of the strongest symmetric profiles. This tooth shape is stronger than a similarly
// sized square thread becuase of its wider base. However, it does place a radial load on the nut, unlike the square thread.
// For loads in only one direction the asymmetric buttress thread profile can bear greater loads.
// .
// By default produces the nominal dimensions
// for metric trapezoidal threads: a thread angle of 30 degrees and a depth set to half the pitch.
// You can also specify your own trapezoid parameters. For ACME threads see acme_threaded_rod().
// Figure(2D,Med,NoAxes):
// pa_delta = tan(15)/4;
// rr1 = -1/2;
// z1 = 1/4-pa_delta;
// z2 = 1/4+pa_delta;
// profile = [
// [-z2, rr1],
// [-z1, 0],
// [ z1, 0],
// [ z2, rr1],
// ];
// fullprofile = 50*left(1/2,p=concat(profile, right(1, p=profile)));
// stroke(fullprofile,width=1);
// dir = fullprofile[2]-fullprofile[3];
// dir2 = fullprofile[5]-fullprofile[4];
// curve = arc(32,angle=[75,105],r=67.5);
// avgpt = mean([fullprofile[5]+.1*dir2, fullprofile[5]+.4*dir2]);
// color("red"){
// stroke([fullprofile[2]+.1*dir, fullprofile[2]+.4*dir], width=1);
// stroke([fullprofile[5]+.1*dir2, fullprofile[5]+.4*dir2], width=1);
// stroke(move(-curve[0]+avgpt,p=curve), width=1,endcaps="arrow2");
// back(10)text("thread",size=4,halign="center");
// back(3)text("angle",size=4,halign="center");
// }
// Figure(2D,Med,NoAxes):
// pa_delta = tan(15)/4;
// rr1 = -1/2;
// z1 = 1/4-pa_delta;
// z2 = 1/4+pa_delta;
// profile = [
// [-z2, rr1],
// [-z1, 0],
// [ z1, 0],
// [ z2, rr1],
// ];
// fullprofile = 50*left(1/2,p=concat(profile, right(1, p=profile)));
// stroke(fullprofile,width=1);
// dir = fullprofile[2]-fullprofile[3];
// dir2 = fullprofile[5]-fullprofile[4];
// curve = arc(15,angle=[75,87],r=40 /*67.5*/);
// avgpt = mean([fullprofile[5]+.1*dir2, fullprofile[5]+.4*dir2]);
// color("red"){
// stroke([fullprofile[4]+[0,1], fullprofile[4]+[0,37]], width=1);
// stroke([fullprofile[5]+.1*dir2, fullprofile[5]+.4*dir2], width=1);
// stroke(move(-curve[0]+avgpt,p=curve), width=0.71,endcaps="arrow2");
// right(14)back(19)text("flank",size=4,halign="center");
// right(14)back(14)text("angle",size=4,halign="center");
// }
// Arguments:
// d = Outer diameter of threaded rod.
// l / length / h / height = Length of threaded rod.
// pitch = Thread spacing.
// ---
// thread_angle = Angle between two thread faces. Default: 30
// thread_depth = Depth of threads. Default: pitch/2
// flank_angle = Angle of thread faces to plane perpendicular to screw.
// left_handed = If true, create left-handed threads. Default: false
// starts = The number of lead starts. Default: 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// internal = If true, make this a mask for making internal threads. Default: false
// d1 = Bottom outside diameter of threads.
// d2 = Top outside diameter of threads.
// blunt_start = If true apply truncated blunt start threads at both ends. Default: true
// blunt_start1 = If true apply truncated blunt start threads bottom end.
// blunt_start2 = If true apply truncated blunt start threads top end.
// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0
// end_len1 = Specify unthreaded length at the bottom
// end_len2 = Specify unthreaded length at the top
// lead_in = Specify linear length of the lead in section of the threading with blunt start threads
// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads
// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads
// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads
// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads
// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads
// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default"
// teardrop = If true, adds a teardrop profile to the back (Y+) side of the threaded rod, for 3d printability of horizontal holes. If numeric, specifies the proportional extra distance of the teardrop flat top from the screw center, or set to "max" for a pointed teardrop. Default: false
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Example(2D):
// projection(cut=true)
// trapezoidal_threaded_rod(d=10, l=15, pitch=2, orient=BACK);
// Examples(Med):
// trapezoidal_threaded_rod(d=10, l=40, pitch=2, $fn=32); // Standard metric threading
// rot(-65)trapezoidal_threaded_rod(d=10, l=17, pitch=2, blunt_start=false, $fn=32); // Standard metric threading
// trapezoidal_threaded_rod(d=10, l=17, pitch=2, bevel=true, $fn=32); // Standard metric threading
// trapezoidal_threaded_rod(d=10, h=30, pitch=2, left_handed=true, $fa=1, $fs=1); // Standard metric threading
// trapezoidal_threaded_rod(d=10, l=40, pitch=3, left_handed=true, starts=3, $fn=36);
// trapezoidal_threaded_rod(l=25, d=10, pitch=2, starts=3, $fa=1, $fs=1, bevel=true, orient=RIGHT, anchor=BOTTOM);
// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, blunt_start=false, $fa=2, $fs=2);
// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, end_len=0, $fa=2, $fs=2);
// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, left_handed=true, starts=4, $fa=2, $fs=2,end_len=0);
// trapezoidal_threaded_rod(d=16, l=40, pitch=2, thread_angle=60);
// trapezoidal_threaded_rod(d=25, l=40, pitch=10, thread_depth=8/3, thread_angle=100, starts=4, anchor=BOT, $fa=2, $fs=2,end_len=-2);
// trapezoidal_threaded_rod(d=50, l=35, pitch=8, thread_angle=60, starts=11, lead_in=3, $fn=120);
// trapezoidal_threaded_rod(d=10, l=40, end_len2=10, pitch=2, $fn=32); // Unthreaded top end section
// Example(Med): Using as a Mask to Make Internal Threads
// bottom_half() difference() {
// cube(50, center=true);
// trapezoidal_threaded_rod(d=40, l=51, pitch=5, thread_angle=30, internal=true, bevel=true, orient=RIGHT, $fn=36);
// }
// Example(Med;VPR=[100,0,5];VPD=220): Masking a Horizontal Threaded Hole
// difference() {
// cuboid(50);
// trapezoidal_threaded_rod(
// d=25, l=51, pitch=4, $fn=36,
// thread_angle=30,
// internal=true, bevel=true,
// blunt_start=false,
// teardrop=true, orient=FWD
// );
// }
function trapezoidal_threaded_rod(
d, l, pitch,
thread_angle,
thread_depth,
flank_angle,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
internal=false,
d1, d2, length, h, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
teardrop=false,
anchor, spin, orient
) = no_function("trapezoidal_threaded_rod");
module trapezoidal_threaded_rod(
d, l, pitch,
thread_angle,
thread_depth,
flank_angle,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
internal=false,
d1, d2, length, h, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
teardrop=false,
anchor, spin, orient
) {
dummy0 = assert(num_defined([thread_angle,flank_angle])<=1, "Cannot define both flank angle and thread angle");
thread_angle = first_defined([thread_angle, u_mul(2,flank_angle), 30]);
dummy1 = assert(all_nonnegative(pitch),"Must give a positive pitch value")
assert(thread_angle>=0 && thread_angle<180, "Invalid thread angle or flank angle")
assert(thread_angle<=90 || all_positive([thread_depth]),
"Thread angle (2*flank_angle) must be smaller than 90 degrees with default thread depth of pitch/2");
depth = first_defined([thread_depth,pitch/2]);
pa_delta = 0.5*depth*tan(thread_angle/2) / pitch;
dummy2 = assert(pa_delta<=1/4, "Specified thread geometry is impossible");
rr1 = -depth/pitch;
z1 = 1/4-pa_delta;
z2 = 1/4+pa_delta;
profile = [
[-z2, rr1],
[-z1, 0],
[ z1, 0],
[ z2, rr1],
];
generic_threaded_rod(d=d,l=l,pitch=pitch,profile=profile,
left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,d1=d1,d2=d2,
internal=internal, length=length, height=height, h=h,
blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2,
lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape,
lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2,
end_len=end_len, end_len1=end_len1, end_len2=end_len2,
teardrop=teardrop, anchor=anchor,spin=spin,orient=orient)
children();
}
// Module: trapezoidal_threaded_nut()
// Synopsis: Creates a trapezoidal threaded nut.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: trapezoidal_threaded_rod()
// Usage:
// trapezoidal_threaded_nut(nutwidth, id, h|height|thickness, pitch, [thread_angle=|flank_angle=], [thread_depth], ...) [ATTACHMENTS];
// Description:
// Constructs a hex nut or square nut for a symmetric trapzoidal threaded rod. By default produces
// the nominal dimensions for metric trapezoidal threads: a thread angle of 30 degrees and a depth
// set to half the pitch. You can also specify your own trapezoid parameters. For ACME threads see
// acme_threaded_nut().
// Arguments:
// nutwidth = flat to flat width of nut
// id = inner diameter of threaded hole, measured from bottom of threads
// h / height / l / length / thickness = height/thickness of nut.
// pitch = Thread spacing.
// ---
// thread_angle = Angle between two thread faces. Default: 30
// thread_depth = Depth of the threads. Default: pitch/2
// flank_angle = Angle of thread faces to plane perpendicular to screw.
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default = 1
// bevel = if true, bevel the outside of the nut. Default: true for hex nuts, false for square nuts
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 30
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// blunt_start = If true apply truncated blunt start threads at both ends. Default: true
// blunt_start1 = If true apply truncated blunt start threads bottom end.
// blunt_start2 = If true apply truncated blunt start threads top end.
// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0
// end_len1 = Specify unthreaded length at the bottom
// end_len2 = Specify unthreaded length at the top
// lead_in = Specify linear length of the lead in section of the threading with blunt start threads
// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads
// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads
// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads
// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads
// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads
// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default"
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Examples(Med):
// trapezoidal_threaded_nut(nutwidth=16, id=8, h=8, pitch=2, $slop=0.1, anchor=UP);
// trapezoidal_threaded_nut(nutwidth=16, id=8, h=8, pitch=2, bevel=false, $slop=0.05, anchor=UP);
// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, $slop=0.1, left_handed=true);
// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15);
// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15, blunt_start=false);
// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=0, $slop=0.2); // No threads
function trapezoidal_threaded_nut(
nutwidth,
id,
h,
pitch,
thread_angle,
thread_depth, shape="hex",
flank_angle,
left_handed=false,
starts=1,
bevel,bevel1,bevel2,bevang=30,
ibevel1,ibevel2,ibevel,
thickness,height,
id1,id2,
length, l,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
) = no_function("trapezoidal_threaded_nut");
module trapezoidal_threaded_nut(
nutwidth,
id,
h,
pitch,
thread_angle,
thread_depth, shape="hex",
flank_angle,
left_handed=false,
starts=1,
bevel,bevel1,bevel2,bevang=30,
ibevel1,ibevel2,ibevel,
thickness,height,
id1,id2,
length, l,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
) {
dummy0 = assert(num_defined([thread_angle,flank_angle])<=1, "Cannot define both flank angle and thread angle");
thread_angle = first_defined([thread_angle, u_mul(2,flank_angle), 30]);
dummy1 = assert(all_nonnegative(pitch),"Must give a positive pitch value")
assert(thread_angle>=0 && thread_angle<180, "Invalid thread angle or flank angle")
assert(thread_angle<=90 || all_positive([thread_depth]),
"Thread angle (2*flank_angle) must be smaller than 90 degrees with default thread depth of pitch/2");
depth = first_defined([thread_depth,pitch/2]);
pa_delta = 0.5*depth*tan(thread_angle/2) / pitch;
dummy2 = assert(pitch==0 || pa_delta<1/4, "Specified thread geometry is impossible");
rr1 = -depth/pitch;
z1 = 1/4-pa_delta;
z2 = 1/4+pa_delta;
profile = [
[-z2, rr1],
[-z1, 0],
[ z1, 0],
[ z2, rr1],
];
generic_threaded_nut(nutwidth=nutwidth,id=id,h=h,pitch=pitch,profile=profile,id1=id1,id2=id2,
shape=shape,left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,
ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2,bevang=bevang,height=height,thickness=thickness,
blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2,
lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape,
lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2,
end_len=end_len, end_len1=end_len1, end_len2=end_len2,
l=l,length=length,
anchor=anchor,spin=spin,orient=orient)
children();
}
// Module: acme_threaded_rod()
// Synopsis: Creates an ACME threaded rod.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: acme_threaded_nut()
// Usage:
// acme_threaded_rod(d, l|length, tpi|pitch=, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs an ACME trapezoidal threaded screw rod. This form has a 29 degree thread angle with a
// symmetric trapezoidal thread.
// Arguments:
// d = Outer diameter of threaded rod.
// l / length / h / height = Length of threaded rod.
// tpi = threads per inch.
// ---
// pitch = thread spacing (alternative to tpi)
// starts = The number of lead starts. Default = 1
// left_handed = if true, create left-handed threads. Default = false
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// internal = If true, this is a mask for making internal threads.
// blunt_start = If true apply truncated blunt start threads at both ends. Default: true
// blunt_start1 = If true apply truncated blunt start threads bottom end.
// blunt_start2 = If true apply truncated blunt start threads top end.
// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0
// end_len1 = Specify unthreaded length at the bottom
// end_len2 = Specify unthreaded length at the top
// lead_in = Specify linear length of the lead in section of the threading with blunt start threads
// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads
// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads
// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads
// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads
// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads
// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default"
// teardrop = If true, adds a teardrop profile to the back (Y+) side of the threaded rod, for 3d printability of horizontal holes. If numeric, specifies the proportional extra distance of the teardrop flat top from the screw center, or set to "max" for a pointed teardrop. Default: false
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Example(2D):
// projection(cut=true)
// acme_threaded_rod(d=10, l=15, pitch=2, orient=BACK);
// Examples(Med):
// acme_threaded_rod(d=3/8*INCH, l=20, pitch=1/8*INCH, $fn=32);
// acme_threaded_rod(d=10, l=30, pitch=2, starts=3, $fa=1, $fs=1);
// Example(Med;VPR=[100,0,5];VPD=220): Masking a Horizontal Threaded Hole
// difference() {
// cuboid(50);
// acme_threaded_rod(
// d=25, l=51, pitch=4, $fn=36,
// internal=true, bevel=true,
// blunt_start=false,
// teardrop=true, orient=FWD
// );
// }
function acme_threaded_rod(
d, l, tpi, pitch,
starts=1,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
d1, d2, length, h, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
teardrop=false,
anchor, spin, orient
) = no_function("acme_threaded_rod");
module acme_threaded_rod(
d, l, tpi, pitch,
starts=1,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
d1, d2, length, h, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
teardrop=false,
anchor, spin, orient
) {
dummy = assert(num_defined([pitch,tpi])==1,"Must give exactly one of pitch and tpi");
pitch = is_undef(pitch) ? INCH/tpi : pitch;
trapezoidal_threaded_rod(
d=d, l=l, pitch=pitch,
thread_angle=29,
thread_depth=pitch/2,
starts=starts,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
internal=internal, length=length, height=height, h=h,
blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2,
lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape,
lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2,
end_len=end_len, end_len1=end_len1, end_len2=end_len2,
teardrop=teardrop,
anchor=anchor,
spin=spin,
orient=orient
) children();
}
// Module: acme_threaded_nut()
// Synopsis: Creates an ACME threaded nut.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: acme_threaded_rod()
// Usage:
// acme_threaded_nut(nutwidth, id, h|height|thickness, tpi|pitch=, [shape=], ...) [ATTACHMENTS];
// Description:
// Constructs a hexagonal or square nut for an ACME threaded screw rod.
// Arguments:
// nutwidth = flat to flat width of nut.
// id = inner diameter of threaded hole, measured from bottom of threads
// h / height / l / length / thickness = height/thickness of nut.
// tpi = threads per inch
// ---
// pitch = Thread spacing (alternative to tpi)
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = Number of lead starts. Default: 1
// bevel = if true, bevel the outside of the nut. Default: true for hex nuts, false for square nuts
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 30
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// blunt_start = If true apply truncated blunt start threads at both ends. Default: true
// blunt_start1 = If true apply truncated blunt start threads bottom end.
// blunt_start2 = If true apply truncated blunt start threads top end.
// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0
// end_len1 = Specify unthreaded length at the bottom
// end_len2 = Specify unthreaded length at the top
// lead_in = Specify linear length of the lead in section of the threading with blunt start threads
// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads
// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads
// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads
// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads
// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads
// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default"
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Examples(Med):
// acme_threaded_nut(nutwidth=16, id=3/8*INCH, h=8, tpi=8, $slop=0.05);
// acme_threaded_nut(nutwidth=16, id=3/8*INCH, h=10, tpi=12, starts=3, $slop=0.1, $fa=1, $fs=1, ibevel=false);
// acme_threaded_nut(nutwidth=16, id=3/8*INCH, h=10, tpi=12, starts=3, $slop=0.1, $fa=1, $fs=1, blunt_start=false);
function acme_threaded_nut(
nutwidth, id, h, tpi, pitch,
starts=1,
left_handed=false,shape="hex",
bevel,bevel1,bevel2,bevang=30,
ibevel,ibevel1,ibevel2,
height,thickness,
length, l,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
) = no_function("acme_threaded_nut");
module acme_threaded_nut(
nutwidth, id, h, tpi, pitch,
starts=1,
left_handed=false,shape="hex",
bevel,bevel1,bevel2,bevang=30,
ibevel,ibevel1,ibevel2,
height,thickness,
length, l,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
) {
dummy = assert(num_defined([pitch,tpi])==1,"Must give exactly one of pitch and tpi");
pitch = is_undef(pitch) ? INCH/tpi : pitch;
dummy2=assert(is_num(pitch) && pitch>=0);
trapezoidal_threaded_nut(
nutwidth=nutwidth, id=id, h=h, pitch=pitch,
thread_depth = pitch/2,
thread_angle=29,shape=shape,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2,
height=height,thickness=thickness,
blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2,
lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape,
lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2,
end_len=end_len, end_len1=end_len1, end_len2=end_len2,
l=l,length=length,
starts=starts,
anchor=anchor,
spin=spin,
orient=orient
) children();
}
// Section: Pipe Threading
// Module: npt_threaded_rod()
// Synopsis: Creates NPT pipe threading.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: acme_threaded_rod()
// Usage:
// npt_threaded_rod(size, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a standard NPT pipe end threading. If `internal=true`, creates a mask for making
// internal pipe threads. Tapers smaller upwards if `internal=false`. Tapers smaller downwards
// if `internal=true`. If `hollow=true` and `internal=false`, then the pipe threads will be
// hollowed out into a pipe with the apropriate internal diameter.
// Arguments:
// size = NPT standard pipe size in inches. 1/16", 1/8", 1/4", 3/8", 1/2", 3/4", 1", 1+1/4", 1+1/2", or 2". Default: 1/2"
// ---
// left_handed = If true, create left-handed threads. Default = false
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// hollow = If true, create a pipe with the correct internal diameter.
// internal = If true, make this a mask for making internal threads.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Example(2D): The straight gray rectangle reveals the tapered threads.
// projection(cut=true) npt_threaded_rod(size=1/4, orient=BACK);
// right(.533*INCH/2) color("gray") rect([2,0.5946*INCH],anchor=LEFT);
// Examples(Med):
// npt_threaded_rod(size=3/8, $fn=72);
// npt_threaded_rod(size=1/2, $fn=72, bevel=true);
// npt_threaded_rod(size=1/2, left_handed=true, $fn=72);
// npt_threaded_rod(size=3/4, hollow=true, $fn=96);
// Example:
// diff("remove"){
// cuboid([40,40,40])
// tag("remove"){
// up(.01)position(TOP)
// npt_threaded_rod(size=3/4, $fn=96, internal=true, $slop=0.1, anchor=TOP);
// cyl(d=3/4*INCH, l=42, $fn=32);
// }
// }
function npt_threaded_rod(
size=1/2,
left_handed=false,
bevel,bevel1,bevel2,
hollow=false,
internal=false,
anchor, spin, orient
)=no_function("npt_threaded_rod");
module npt_threaded_rod(
size=1/2,
left_handed=false,
bevel,bevel1,bevel2,