-
Notifications
You must be signed in to change notification settings - Fork 11
/
tensioner_clss_new.py
2514 lines (2237 loc) · 105 KB
/
tensioner_clss_new.py
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
import os
import sys
import inspect
import logging
import math
import FreeCAD
import FreeCADGui
import Part
import DraftVecUtils
import kcomp # import material constants and other constants
from NuevaClase import Obj3D
import fc_clss_new
import fcfun # import my functions for freecad. FreeCad Functions
import comps # import my CAD components
import shp_clss
from fcfun import V0, VX, VY, VZ, V0ROT
from fcfun import VXN, VYN, VZN
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
class BearWashSet(Obj3D):
""" A set of bearings and washers, usually to make idle pulleys
Parameters:
-----------
metric : int
Metric (diameter) of the bolt that holds the set
axis_h : FreeCAD.Vector
vector along the cylinder height
pos_h : int
location of pos along axis_h (0,1,2,3)
0: pos is centered along its height
1: pos is at the base of the bearing
2: pos is at the base of the regular washer
3: pos is at the base of the large washer (this is the bottom)
axis_d : FreeCAD.Vector
vector perpendicular to the axis_h, along the radius
pos_d : int
location of pos along axis_d (0,1,2,3)
0: pos is centered at the cylinder axis
1: pos is at the bearing internal radius (defined by netric)
2: pos is at the bearing external radius
3: pos is at the large washer external radius
axis_w : FreeCAD.Vector
vector perpendicular to the axis_h and axis_d, along the radius
pos_w : int
location of pos along axis_w (0,1,2,3)
0: pos is centered at the cylinder axis
1: pos is at the bearing internal radius (defined by netric)
2: pos is at the bearing external radius
3: pos is at the large washer external radius
group : int
1: make a group
0: leave as individual components
pos : FreeCAD.Vector
Position of the cylinder, taking into account where the center is
Attributes:
-----------
metric : int or float (in case of M2.5) or even str for inches ?
Metric of the washer
pos_o : FreeCAD.Vector
Position of the origin of the shape
h_o : dictionary of FreeCAD.Vector
vectors from the origin to the different points along axis_h
d_o : dictionary of FreeCAD.Vector
vectors from the origin to the different points along axis_d
w_o : dictionary of FreeCAD.Vector
vectors from the origin to the different points along axis_w
h0_cen : int
d0_cen : int
w0_cen : int
indicates if pos_h = 0 (pos_d, pos_w) is at the center along
axis_h, axis_d, axis_w, or if it is at the end.
1 : at the center (symmetrical, or almost symmetrical)
0 : at the end
tot_h : float
Total height of the set: idler pulley
r_in : float
inner radius, the radius of the bearing
r_ext : float
external radius, the radius of the large washer
idler pulley without the washer for the bolt because it is between a holder,
The holder is in dots, not in the group
pos_o is at the center of symmetry: see o in the drawing
axis_h
: pos_h
...:...
: : bolt head
..........:.....:........
: Holder for the pulley group
....._________________...:
|_________________| 3 large washer
|_________| 2 regular washer
| | 1
| o | 0 bearing
|_________| -1
___|_________|___ -2 regular washer
....|_________________|.. -3 large washer
:
.........................: Holder for the pulley group
:.....: nut
:.: bolt shank
01 2 3 pos_d, pos_w
"""
# large washer (din9021) metric
lwash_m_dict = {3: 4, 4: 6}
# regular washer (din125) has the same metric as the pulley
# bearing type
bear_m_dict = {3: 603, 4: 624}
def __init__(self, metric,
axis_h, pos_h,
axis_d=None, pos_d=0,
axis_w=None, pos_w=0,
pos=V0,
group=1,
name=None):
self.pos = FreeCAD.Vector(0, 0, 0)
self.position = pos
if name == None:
name = 'bearing_idlpulley_m' + str(metric)
self.name = name
super().__init__(axis_d, axis_w, axis_h, self.name)
# save the arguments as attributes:
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
for i in args:
if not hasattr(self, i): # so we keep the attributes by CylHole
setattr(self, i, values[i])
try:
# lwash_m is the size (metric) of the large washer
self.lwash_m = self.lwash_m_dict[metric]
# bear_type is the type of bearing, such as 603, 624,...
self.bear_type = self.bear_m_dict[metric]
# lwash_dict is the dictionary with the dimensions of large washer
self.lwash_dict = kcomp.D9021[self.lwash_m]
# rwash_dict is the dictionary with the dimensions of regular washer
self.rwash_dict = kcomp.D125[metric]
# bear is the dictionary with the dimensions of the bearing
self.bear_dict = kcomp.BEARING[self.bear_type]
except KeyError:
logger.error('Bearing/washer key not found: ' + str(metric))
else:
# dimensions of each element
# height, along axis_h
self.lwash_h = self.lwash_dict['t'] # height (thickness)
self.lwash_r_out = self.lwash_dict['do'] / 2.
self.rwash_h = self.rwash_dict['t'] # height (thickness)
self.rwash_r_out = self.rwash_dict['do'] / 2.
self.bear_h = self.bear_dict['t'] # height (thickness)
self.bear_r_out = self.bear_dict['do'] / 2.
# total height:
self.tot_h = 2 * (self.lwash_h + self.rwash_h) + self.bear_h
# inner radius of the pulley, the radius of the bearing
self.r_in = self.bear_r_out
# external radius, the radius of the large washer
self.r_ext = self.lwash_r_out
# pos_h/d/w = 0 are at the center
self.h0_cen = 1
self.d0_cen = 1
self.w0_cen = 1
# the origin (pos_o) is at the center of symmetry
# vectors from o (orig) along axis_h, to the pos_h points
# h_o is a dictionary created in Obj3D.__init__
self.h_o[0] = V0
self.h_o[1] = self.vec_h(-self.bear_h / 2.)
self.h_o[2] = self.vec_h(-self.bear_h / 2. - self.rwash_h)
self.h_o[3] = self.vec_h(- self.bear_h / 2.
- self.rwash_h
- self.lwash_h)
self.d_o[0] = V0
if self.axis_d is not None:
self.d_o[1] = self.vec_d(-metric / 2.)
self.d_o[2] = self.vec_d(-self.bear_r_out)
self.d_o[3] = self.vec_d(-self.lwash_r_out)
elif pos_d != 0:
logger.error('axis_d not defined while pos_d != 0')
self.w_o[0] = V0
if self.axis_d is not None:
self.w_o[1] = self.vec_w(-metric / 2.)
self.w_o[2] = self.vec_w(-self.bear_r_out)
self.w_o[3] = self.vec_w(-self.lwash_r_out)
elif pos_w != 0:
logger.error('axis_w not defined while pos_w != 0')
# calculates the position of the origin, and keeps it in attribute
# pos_o
self.set_pos_o()
# creation of the bearing
bearing = fc_clss_new.BearingOutl(bearing_nb=self.bear_type,
axis_h=self.axis_h,
pos_h=0,
axis_d=self.axis_d,
axis_w=self.axis_w,
pos=self.pos_o,
# pos = rwash_b.get_pos_h(1),
name='idlpull_bearing')
super().append_part(bearing)
# creation of the bottom regular washer
rwash_b = fc_clss_new.Din125Washer(metric=metric,
axis_h=self.axis_h,
pos_h=1,
pos=bearing.get_pos_h(-1),
name='idlpull_rwash_bt')
super().append_part(rwash_b)
# creation of the bottom large washer
lwash_b = fc_clss_new.Din9021Washer(metric=self.lwash_m,
axis_h=self.axis_h,
pos_h=1,
pos=rwash_b.get_pos_h(-1),
name='idlpull_lwash_bt')
super().append_part(lwash_b)
# creation of the top regular washer
rwash_t = fc_clss_new.Din125Washer(metric=metric,
axis_h=self.axis_h,
pos_h=-1,
pos=bearing.get_pos_h(1),
name='idlpull_rwash_tp')
super().append_part(rwash_t)
# creation of the top large washer
lwash_t = fc_clss_new.Din9021Washer(metric=self.lwash_m,
axis_h=self.axis_h,
pos_h=-1,
pos=rwash_t.get_pos_h(1),
name='idlpull_lwash_tp')
super().append_part(lwash_t)
if group == 1:
super().make_group()
# Need to set first in (0,0,0) and after that set the real placement.
# This enable to do rotations without any issue
self.fco.Placement.Base = FreeCAD.Vector(0, 0, 0)
self.fco.Placement.Base = self.position
class Din912BoltWashSet(Obj3D):
""" A din 912 bolt and a wahser set
Parameters:
-----------
metric : int (could be 2.5)
Metric (diameter) of the bolt
shank_l : float
length of the bolt, not including the head
the real length depends on shank_l_adjust
wide_washer : int
0: normal washer (default) din 125
1: wide washer din 9021
shank_l_adjust : int
0: shank length will be the size of the parameter shank_l
-1: shank length will be the size of the closest shorter or equal
to shank_l available lengths for this type of bolts
1: shank length will be the size of the closest larger or equal
to shank_l available lengths for this type of bolts
-2: shank length will be the size of the closest shorter or equal
to shank_l + washer thick available lengths for this type of bolts
available lengths for this type of bolts
2: shank length will be the size of the closest larger or equal
to shank_l + washer thick available lengths for this type of bolts
shank_out : float
0: default
distance to the end of the shank, just for positioning, it doesn't
change shank_l
I don't think it is necessary, but just in case
head_out : float
0: default
distance to the end of the head, just for positioning, it doesn't
change head_l
I don't think it is necessary, but just in case
axis_h : FreeCAD.Vector
vector along the bolt axis
axis_d : FreeCAD.Vector
vector along the radius, a direction perpendicular to axis_h
if head is hexagonal or the socket, it will point the direction of a
vertex
axis_w : FreeCAD.Vector
vector along the other radius, a direction perpendicular to axis_h
and axis_d
it is not necessary if pos_w == 0
It can be None
pos_h : int
location of pos along axis_h
0: top of the head, considering head_out,
1: position of the head not considering head_out
if head_out = 0, it will be the same as pos_h = 0
2: union of the head and the shank, beginning of the washer
3: end of the washer
4: where the screw starts, if all the shank is screwed, it will be
the same as pos_h = 2
5: end of the shank, not considering shank_out
6: end of the shank, if shank_out = 0, will be the same as pos_h = 5
6: top of the head, considering xtr_head_l, if xtr_head_l = 0
will be the same as pos_h = 0
pos_d : int
location of pos along axis_d (symmetric)
0: pos is at the central axis
1: radius of the shank
2: radius of the head
3: outer radius of the washer
pos_w : int
location of pos along axis_d (symmetric)
0: pos is at the central axis
1: radius of the shank
2: radius of the head
3: outer radius of the washer
axis_w : FreeCAD.Vector
vector perpendicular to the axis_h and axis_d, along the radius
pos_w : int
location of pos along axis_w (0,1,2,3)
0: pos is centered at the cylinder axis
1: pos is at the bearing internal radius (defined by netric)
2: pos is at the bearing external radius
3: pos is at the large washer external radius
group : int
1: make a group
0: leave as individual components
pos : FreeCAD.Vector
Position of the cylinder, taking into account where the center is
axis_h
:
: shank_r
:+
: :
: :
....6......... _:_:...................
shank_out+....5.........| : | : :
| : | + thread_l :
| : | : :
| : | : :
| : | : + shank_l
4 |.:.|....: :
| : | :
| : | :
.... 3 _______|_:_|_______ :
washer_thick : | :: : :: | :
:... 2 |______::_:_::______|..........:
| : | :
| ..:.. | + head_l
...1......| : : : | :
head_out+...0......|__:_:_:__|...............:.... axis_d
0 1 2 3
: : :
:....: :
: + :
: head_r :
: :
:.........:
+ washer_ro
"""
def __init__(self, metric,
shank_l,
wide_washer=0,
shank_l_adjust=0,
shank_out=0,
head_out=0,
axis_h=VZ,
axis_d=None, axis_w=None,
pos_h=0, pos_d=0, pos_w=0,
pos=V0,
group=1, # 1: make a group
name=None):
if name == None:
name = 'd912bolt_washer_m' + str(int(metric))
self.name = name
self.pos = FreeCAD.Vector(0, 0, 0)
self.position = pos
Obj3D.__init__(self, axis_d, axis_w, axis_h, self.name)
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
for i in args:
if not hasattr(self, i): # so we keep the attributes by CylHole
setattr(self, i, values[i])
self.bolt_dict = kcomp.D912[metric]
if wide_washer == 0:
self.washer_dict = kcomp.D125[metric]
else:
self.washer_dict = kcomp.D9021[metric]
self.washer_thick = self.washer_dict['t']
self.washer_do = self.washer_dict['do']
self.washer_ro = self.washer_do / 2.
if shank_l_adjust == 0:
self.shank_l = shank_l
else:
sh_l_list = self.bolt_dict['shank_l_list']
if shank_l_adjust == -1: # smaller closest to shank_l
self.shank_l = [sh_l for sh_l in sh_l_list if sh_l <= shank_l][-1]
elif shank_l_adjust == 1: # larger closest to shank_l
self.shank_l = [sh_l for sh_l in sh_l_list if sh_l >= shank_l][0]
elif shank_l_adjust == -2: # smaller closest to shank_l, washer
self.shank_l = [sh_l for sh_l in sh_l_list
if sh_l <= shank_l + self.washer_thick][-1]
elif shank_l_adjust == 2: # larger closest to shank_l + washer_thick
self.shank_l = [sh_l for sh_l in sh_l_list
if sh_l >= shank_l + self.washer_thick][0]
else:
logger.error('wrong value for parameter shank_l_adjust')
self.shank_l = shank_l
if self.bolt_dict['thread'] > self.shank_l:
self.thread_l = self.shank_l
else:
self.thread_l = self.bolt_dict['thread']
self.shank_r = metric / 2.
self.head_l = self.bolt_dict['head_l']
self.head_r = self.bolt_dict['head_r']
self.h0_cen = 0
self.d0_cen = 1 # symmetrical
self.w0_cen = 1 # symmetrical
self.tot_l = self.head_l + self.shank_l
# vectors from o (orig) along axis_h, to the pos_h points
# h_o is a dictionary created in Obj3D.__init__
self.h_o[0] = V0 # origin
self.h_o[1] = self.vec_h(head_out)
self.h_o[2] = self.vec_h(self.head_l)
self.h_o[3] = self.vec_h(self.head_l + self.washer_thick)
self.h_o[4] = self.vec_h(self.tot_l - self.thread_l)
self.h_o[5] = self.vec_h(self.tot_l - shank_out)
self.h_o[6] = self.vec_h(self.tot_l)
self.d_o[0] = V0
if not (self.axis_d is None or self.axis_d == V0):
# negative because is symmetric
self.d_o[1] = self.vec_d(-self.shank_r)
self.d_o[2] = self.vec_d(-self.head_r)
self.d_o[3] = self.vec_d(-self.washer_ro)
elif pos_d != 0:
logger.error('axis_d not defined while pos_d != 0')
self.w_o[0] = V0
if not (self.axis_w is None or self.axis_w == V0):
# negative because is symmetric
self.w_o[1] = self.vec_w(-self.shank_r)
self.w_o[2] = self.vec_w(-self.head_r)
self.w_o[3] = self.vec_w(-self.washer_ro)
elif pos_w != 0:
logger.error('axis_w not defined while pos_w != 0')
self.set_pos_o()
# creation of the bolt, at the origin self.pos_o:
bolt = fc_clss_new.Din912Bolt(metric=metric,
shank_l=self.shank_l,
shank_out=shank_out,
head_out=head_out,
axis_h=self.axis_h,
axis_d=self.axis_d,
axis_w=self.axis_w,
pos_h=0, pos_d=0, pos_w=0,
pos=self.pos_o,
name=None)
self.append_part(bolt)
# creation of the washer, at the origin at pos_h = 2, and at the end
# of the washer, could use an if
if wide_washer == 0:
washer = fc_clss_new.Din125Washer(metric=metric,
axis_h=self.axis_h,
pos_h=-1, # base of cylinder
pos=self.get_pos_h(2),
name=None)
else:
washer = fc_clss_new.Din9021Washer(metric=metric,
axis_h=self.axis_h,
pos_h=-1, # base of cylinder
pos=self.get_pos_h(2),
name=None)
self.append_part(washer)
if group == 1:
super().make_group()
# Need to set first in (0,0,0) and after that set the real placement.
# This enable to do rotations without any issue
self.fco.Placement.Base = FreeCAD.Vector(0, 0, 0)
self.fco.Placement.Base = self.position
class Din934NutWashSet(Obj3D):
""" A din 934 nut and a wahser set
Parameters:
-----------
metric : int (could be 2.5)
Metric (diameter) of the bolt
wide_washer : int
0: normal washer (default) din 125
1: wide washer din 9021
axis_d_apo : int
0: default: axis_d points to the vertex
1: axis_d points to the center of a side
axis_h : FreeCAD.Vector
vector along the bolt axis
axis_d : FreeCAD.Vector
vector along the first vertex, a direction perpendicular to axis_h
it is not necessary if pos_d == 0
It can be None, but if None, axis_w has to be None
vector along the radius, a direction perpendicular to axis_h
axis_w : FreeCAD.Vector
vector along the other radius, a direction perpendicular to axis_h
and axis_d
it is not necessary if pos_w == 0
It can be None
pos_h : int
location of pos along axis_h
0: at the base of the washer
1: end of the washer, beginning of the nut
2: end of the nut
pos_d : int
location of pos along axis_d (symmetric)
0: pos is at the central axis
1: radius of the hole
2: apotheme
3: circumradius
4: radius of the washer
pos_w : int
location of pos along axis_d (symmetric)
0: pos is at the central axis
1: radius of the hole
2: apotheme
3: circumradius
4: radius of the washer
group : int
1: make a group
0: leave as individual components
pos : FreeCAD.Vector
Position of the cylinder, taking into account where the center is
axis_h
:
: metric/2
:+
: :
: :
2 ____:____ :
| : | : | + head_l
| : | : | :
.... 1 ____|__:_:_:__|____ :
washer_thick : | : : : | :
:... 0 |_______:_:_:_______|...........axis_d
0 1 23 4
: : :
:....: :
: + :
: head_r :
: :
:.........:
+ washer_ro
"""
def __init__(self, metric,
wide_washer=0,
axis_d_apo=0,
axis_h=VZ,
axis_d=None, axis_w=None,
pos_h=0, pos_d=0, pos_w=0,
pos=V0,
group=1, # 1: make a group
name=None):
self.pos = FreeCAD.Vector(0, 0, 0)
self.position = pos
if name == None:
name = 'd934' + str(int(metric))
self.name = name
Obj3D.__init__(self, axis_d, axis_w, axis_h, name)
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
for i in args:
if not hasattr(self, i): # so we keep the attributes by CylHole
setattr(self, i, values[i])
self.nut_dict = kcomp.D934[metric]
self.nut_h = self.nut_dict['l']
self.nut_ro = self.nut_dict['circ_r']
# either or the next, not exact
# self.nut_apo = self.nut_dict['a2']/2.
self.nut_apo = self.nut_ro * 0.866 # cos 30
if wide_washer == 0:
self.washer_dict = kcomp.D125[metric]
else:
self.washer_dict = kcomp.D9021[metric]
self.washer_thick = self.washer_dict['t']
self.washer_do = self.washer_dict['do']
self.washer_ro = self.washer_do / 2.
self.h0_cen = 0
self.d0_cen = 1 # symmetrical
self.w0_cen = 1 # symmetrical
self.tot_h = self.nut_h + self.washer_thick
# vectors from o (orig) along axis_h, to the pos_h points
# h_o is a dictionary created in Obj3D.__init__
self.h_o[0] = V0 # origin
self.h_o[1] = self.vec_h(self.washer_thick)
self.h_o[2] = self.vec_h(self.washer_thick + self.nut_h)
self.d_o[0] = V0
if not (self.axis_d is None or self.axis_d == V0):
# negative because is symmetric
self.d_o[1] = self.vec_d(-metric / 2.)
self.d_o[2] = self.vec_d(-self.nut_apo)
self.d_o[3] = self.vec_d(-self.nut_ro)
self.d_o[4] = self.vec_d(-self.washer_ro)
elif pos_d != 0:
logger.error('axis_d not defined while pos_d != 0')
self.w_o[0] = V0
if not (self.axis_w is None or self.axis_w == V0):
# negative because is symmetric
self.w_o[1] = self.vec_w(-metric / 2.)
self.w_o[2] = self.vec_w(-self.nut_apo)
self.w_o[3] = self.vec_w(-self.nut_ro)
self.w_o[4] = self.vec_w(-self.washer_ro)
elif pos_w != 0:
logger.error('axis_w not defined while pos_w != 0')
self.set_pos_o()
# creation of the nut, at pos h = 1
nut = fc_clss_new.Din934Nut(metric=metric,
axis_d_apo=axis_d_apo,
axis_h=self.axis_h,
axis_d=self.axis_d,
axis_w=self.axis_w,
pos_h=-1, pos_d=0, pos_w=0,
pos=self.get_pos_h(1),
name=None)
self.append_part(nut)
# creation of the washer, at the origin , and at the end
# of the washer, could use an if
if wide_washer == 0:
washer = fc_clss_new.Din125Washer(metric=metric,
axis_h=self.axis_h,
pos_h=-1, # base of cylinder
pos=self.pos_o,
name=None)
else:
washer = fc_clss_new.Din9021Washer(metric=metric,
axis_h=self.axis_h,
pos_h=-1, # base of cylinder
pos=self.pos_o,
name=None)
self.append_part(washer)
self.place_fcos()
if group == 1:
super().make_group()
# Need to set first in (0,0,0) and after that set the real placement.
# This enable to do rotations without any issue
self.fco.Placement.Base = FreeCAD.Vector(0, 0, 0)
self.fco.Placement.Base = self.position
class IdlerTensioner(Obj3D):
""" Creates the idler pulley tensioner shape
nut_space
.+..
: :
nut_holder_thick: :nut_holder_thick
+: :+
: : : : pulley_stroke_dist
: : : : : .+.
: : : : : : : idler_r_ext
: : : : : : :.+..
: : : : : : : : idler_r_int
: : : : : : : :.+...
: : : : : : : : :
________ : :__:_:_______:_:___:____:..................
|___::___| / ____ __:_:___|.....+wall_thick :
| ....| | __ / \ | : + tens_h
| ()...| |:| |:| | | + idler_h :
|________| | -- \_____/ |________....: :
|___::___| \__________________:_:___|.................:
: : : : : :
:........: : :...+...: :
+ :......: tens_stroke :
tens_w : + :
(2*idler_r_int) : nut_holder_tot :
: :
:.........tens_d..........:
pos_h
________ ________________________
|___::___| / ____ ___::___|
| ....| | __ / \ |
| ()...| 0 o:| |:| | | -----> axis_d
|________| 1 | -- \_____/ |________
|___::___| 2 \___________________::___|
1 0 0 1 2 3 4 5 : pos_d
pos_w
pos_o (origin) is at pos_d=0, pos_w=0, pos_h=0, It marked with o
Parameters:
-----------
wall_thick : float
Thickness of the walls
tens_stroke : float
Length of the idler tensioner body, the stroke. Not including the pulley
neither the space for the tensioner bolt
pulley_stroke_dist : float
Distance along axis_d from between the end of the pulley and the stroke
Not including the pulley. See picture dimensions
if 0: it will be the same as wall_thick
nut_holder_thick : float
Length of the space along axis_d above and below the nut, for the bolt
in_fillet: float
radius of the inner fillets
idler_h : float
height of the idler pulley
idler_r_in : float
internal radius of the idler pulley. This is the radius of the surface
where the belt goes
idler_r_ext : float
external radius of the idler pulley. This is the most external part of
the pulley (for example the radius of the large washer)
boltidler_mtr : integer (could be float 2.5)
diameter (metric) of the bolt for the idler pulley
bolttens_mtr : integer (could be float 2.5)
diameter (metric) of the bolt for the tensioner
opt_tens_chmf : int
1: there is a chamfer at every edge of tensioner, inside the holder
0: there is a chamfer only at the edges along axis_w, not along axis_h
tol : float
Tolerances to print
axis_d : FreeCAD.Vector
length vector of coordinate system
axis_w : FreeCAD.Vector
width vector of coordinate system
if V0: it will be calculated using the cross product: axis_d x axis_h
axis_h : FreeCAD.Vector
height vector of coordinate system
pos_d : int
location of pos along the axis_d (0,1,2,3,4,5), see drawing
0: at the back of the holder
1: at the beginning of the hole for the nut (position for the nut)
2: at the beginning of the tensioner stroke hole
3: at the end of the tensioner stroke hole
4: at the center of the idler pulley hole
5: at the end of the piece
pos_w : int
location of pos along the axis_w (0,1) almost symmetrical
0: at the center of symmetry
1: at the end of the piece along axis_w at the negative side
pos_h : int
location of pos along the axis_h (0,1,2), symmetrical
0: at the center of symmetry
1: at the inner base: where the base of the pulley goes
2: at the bottom of the piece (negative side of axis_h)
pos : FreeCAD.Vector
Position of the cylinder, taking into account where the center is
Attributes:
-----------
All the parameters and attributes of parent class SinglePart
Dimensional attributes:
tens_d : float
total length (depth) of the idler tensioner
tens_w : float
total width of the idler tensioner
tens_h : float
total height of the idler tensioner
tens_d_inside : float
length (depth) of the idler tensioner that can be inside the holder
prnt_ax : FreeCAD.Vector
Best axis to print (normal direction, pointing upwards)
d0_cen : int
w0_cen : int
h0_cen : int
indicates if pos_h = 0 (pos_d, pos_w) is at the center along
axis_h, axis_d, axis_w, or if it is at the end.
1 : at the center (symmetrical, or almost symmetrical)
0 : at the end
"""
def __init__(self,
idler_h,
idler_r_in,
idler_r_ext,
in_fillet=2.,
wall_thick=5.,
tens_stroke=20.,
pulley_stroke_dist=0,
nut_holder_thick=4.,
boltidler_mtr=3,
bolttens_mtr=3,
opt_tens_chmf=1,
tol=kcomp.TOL,
axis_d=VX,
axis_w=VY,
axis_h=VZ,
pos_d=0,
pos_w=0,
pos_h=0,
pos=V0,
name='IdlerTensioner'):
Obj3D.__init__(self, axis_d, axis_w, axis_h, name)
self.pos = FreeCAD.Vector(0, 0, 0)
self.position = pos
# save the arguments as attributes:
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
for i in args:
if not hasattr(self, i):
setattr(self, i, values[i])
# calculation of the dimensions:
if pulley_stroke_dist == 0: # default value
self.pulley_stroke_dist = wall_thick
# dictionary of the bolt for the idler pulley
# din 912 bolts are used:
self.boltidler_dict = kcomp.D912[boltidler_mtr]
self.boltidler_r_tol = self.boltidler_dict['shank_r_tol']
# --- tensioner bolt and nut values
# dictionary of the bolt tensioner
self.bolttens_dict = kcomp.D912[bolttens_mtr]
# the shank radius including tolerance
self.bolttens_r_tol = self.bolttens_dict['shank_r_tol']
# dictionary of the nut
self.nuttens_dict = kcomp.D934[bolttens_mtr]
self.nut_space = kcomp.NUT_HOLE_MULT_H + self.nuttens_dict['l_tol']
self.nut_holder_tot = self.nut_space + 2 * nut_holder_thick
# circum diameter of the nut
self.tensnut_circ_d = self.nuttens_dict['circ_d']
# circum radius of the nut, with tolerance
self.tensnut_circ_r_tol = self.nuttens_dict['circ_r_tol']
# the apotheme of the nut
self.tensnut_ap_tol = (self.nuttens_dict['a2'] + tol / 2.) / 2.
# --- idler tensioner dimensions
self.tens_h = idler_h + 2 * wall_thick
self.tens_d = (self.nut_holder_tot
+ tens_stroke
+ self.pulley_stroke_dist
+ idler_r_ext
+ idler_r_in)
self.tens_d_inside = (self.nut_holder_tot
+ tens_stroke
+ self.pulley_stroke_dist)
self.tens_w = max(2 * idler_r_in, self.tensnut_circ_d)
self.d0_cen = 0
self.w0_cen = 1 # symmetrical
self.h0_cen = 1 # symmetrical
self.d_o[0] = V0
self.d_o[1] = self.vec_d(nut_holder_thick)
self.d_o[2] = self.vec_d(self.nut_holder_tot)
self.d_o[3] = self.vec_d(self.nut_holder_tot + tens_stroke)
self.d_o[4] = self.vec_d(self.tens_d - idler_r_in)
self.d_o[5] = self.vec_d(self.tens_d)
# these are negative because actually the pos_w indicates a negative
# position along axis_w
self.w_o[0] = V0
self.w_o[1] = self.vec_w(-self.tens_w / 2.)
self.h_o[0] = V0
self.h_o[1] = self.vec_h(-idler_h / 2.)
self.h_o[2] = self.vec_h(-self.tens_h / 2.)
# calculates the position of the origin, and keeps it in attribute pos_o
self.set_pos_o()
# ------------- building of the piece --------------------
# --------------- step 01-04 ------------------------
# rectangular cuboid with basic dimensions, but chamfered
# at the inner end
#
# axis_h
# : .....tens_d.......
# : : ________________:
# : / /|
# / / |
# .. /_______________/ |.......
# : / | / .
# tens_h | | / . tens_w
# :. \_______________|/......
#
#
# o: shows the position of the origin: pos_o
#
# axis_h axis_h
# : :
# .... ____:____ : ______________________
# : |.........| ch2/ |
# : |: :| | |
# tens_h + |: o :| o |-----> axis_d
# : |:.......:| | |
# :...|_________| ch1\______________________|
# : : : :
# :.tens_h..: :...... tens_d .........:
#
# ____o____ ....> axis_w
# ch3/_________\ch4
# | | chamfer ch3 and ch4 are optional
# | | Depending on opt_tens_chmf
# | |
# | |
# | |
# | |
# |.........|
# | |
# | |
# | |
# |_________|
# :
# :
# V
# axis_d
if opt_tens_chmf == 0: # no optional chamfer, only along axis_w
edge_dir = self.axis_w
else:
edge_dir = V0
shp01chmf = fcfun.shp_boxdir_fillchmfplane(box_w=self.tens_w,
box_d=self.tens_d,
box_h=self.tens_h,
axis_d=self.axis_d,
axis_h=self.axis_h,
cd=0, cw=1, ch=1,
# no tolerances, this is the piece
fillet=0, # chamfer
radius=2 * in_fillet,
plane_fill=self.axis_d.negative(),
both_planes=0,
edge_dir=edge_dir,
pos=self.pos_o)
super().add_child(shp01chmf, 1, 'shp01chmf')
# --------------- step 02 ---------------------------
# Space for the idler pulley
# axis_h
# :
# : ______________________
# / _______|....
# | | + idler_h
# | | 5 :----------->axis_d