@@ -499,6 +499,7 @@ def __init__(self, obj):
499
499
self .add_computed_properties (obj )
500
500
self .add_tolerance_properties (obj )
501
501
self .add_involute_properties (obj )
502
+ self .add_fillet_properties (obj )
502
503
obj .rack = self .involute_rack
503
504
obj .teeth = 15
504
505
obj .module = '1. mm'
@@ -543,49 +544,114 @@ def add_fillet_properties(self, obj):
543
544
obj .addProperty ("App::PropertyFloat" , "head_fillet" , "fillets" , "a fillet for the tooth-head, radius = head_fillet x module" )
544
545
obj .addProperty ("App::PropertyFloat" , "root_fillet" , "fillets" , "a fillet for the tooth-root, radius = root_fillet x module" )
545
546
546
- def generate_gear_shape (self , fp ):
547
- fp .rack .m = fp .module .Value
548
- fp .rack .z = fp .teeth
549
- fp .rack .pressure_angle = fp .pressure_angle .Value * np .pi / 180.
550
- fp .rack .thickness = fp .thickness .Value
551
- fp .rack .beta = fp .beta .Value * np .pi / 180.
552
- fp .rack .head = fp .head
547
+ def generate_gear_shape (self , obj ):
548
+ obj .rack .m = obj .module .Value
549
+ obj .rack .z = obj .teeth
550
+ obj .rack .pressure_angle = obj .pressure_angle .Value * np .pi / 180.
551
+ obj .rack .thickness = obj .thickness .Value
552
+ obj .rack .beta = obj .beta .Value * np .pi / 180.
553
+ obj .rack .head = obj .head
553
554
# checksbackwardcompatibility:
554
- if "clearance" in fp .PropertiesList :
555
- fp .rack .clearance = fp .clearance
556
- if "properties_from_tool" in fp .PropertiesList :
557
- fp .rack .properties_from_tool = fp .properties_from_tool
558
- if "add_endings" in fp .PropertiesList :
559
- fp .rack .add_endings = fp .add_endings
560
- if "simplified" in fp .PropertiesList :
561
- fp .rack .simplified = fp .simplified
562
- fp .rack ._update ()
555
+ if "clearance" in obj .PropertiesList :
556
+ obj .rack .clearance = obj .clearance
557
+ if "properties_from_tool" in obj .PropertiesList :
558
+ obj .rack .properties_from_tool = obj .properties_from_tool
559
+ if "add_endings" in obj .PropertiesList :
560
+ obj .rack .add_endings = obj .add_endings
561
+ if "simplified" in obj .PropertiesList :
562
+ obj .rack .simplified = obj .simplified
563
+ obj .rack ._update ()
564
+
565
+ obj .transverse_pitch = "{} mm" .format (obj .module .Value * np .pi )
566
+ m = obj .module .Value
567
+ t = obj .thickness .Value
568
+ c = obj .clearance
569
+ h = obj .head
570
+ alpha = obj .pressure_angle .Value * np .pi / 180.
571
+ head_fillet = obj .head_fillet
572
+ root_fillet = obj .root_fillet
573
+ x1 = - m * np .pi / 2
574
+ y1 = - m * (1 + c )
575
+ y2 = y1
576
+ x2 = - m * np .pi / 4 + y2 * np .tan (alpha )
577
+ y3 = m * (1 + h )
578
+ x3 = - m * np .pi / 4 + y3 * np .tan (alpha )
579
+ x4 = - x3
580
+ x5 = - x2
581
+ x6 = - x1
582
+ y4 = y3
583
+ y5 = y2
584
+ y6 = y1
585
+ p1 = np .array ([y1 , x1 ])
586
+ p2 = np .array ([y2 , x2 ])
587
+ p3 = np .array ([y3 , x3 ])
588
+ p4 = np .array ([y4 , x4 ])
589
+ p5 = np .array ([y5 , x5 ])
590
+ p6 = np .array ([y6 , x6 ])
591
+ line1 = [p1 , p2 ]
592
+ line2 = [p2 , p3 ]
593
+ line3 = [p3 , p4 ]
594
+ line4 = [p4 , p5 ]
595
+ line5 = [p5 , p6 ]
596
+ tooth = Wire (points_to_wire ([line1 , line2 , line3 , line4 , line5 ]))
597
+ edges = tooth .Edges
598
+ edges = insert_fillet (edges , 0 , m * root_fillet )
599
+ edges = insert_fillet (edges , 2 , m * head_fillet )
600
+ edges = insert_fillet (edges , 4 , m * head_fillet )
601
+ edges = insert_fillet (edges , 6 , m * root_fillet )
602
+
603
+ tooth_edges = [e for e in edges if e is not None ]
604
+ p_end = np .array (tooth_edges [- 2 ].lastVertex ().Point [:- 1 ])
605
+ p_start = np .array (tooth_edges [1 ].firstVertex ().Point [:- 1 ])
606
+ p_start += np .array ([0 , np .pi * m ])
607
+ edge = points_to_wire ([[p_end , p_start ]]).Edges
608
+ tooth = Wire (tooth_edges [1 :- 1 ] + edge )
609
+ teeth = [tooth ]
563
610
564
- # computed properties
565
- if "transverse_pitch" in fp .PropertiesList :
566
- fp .transverse_pitch = "{} mm" .format (fp .rack .compute_properties ()[2 ])
611
+ for i in range (obj .teeth - 1 ):
612
+ tooth = copy .deepcopy (tooth )
613
+ tooth .translate (App .Vector (0 , np .pi * m , 0 ))
614
+ teeth .append (tooth )
567
615
568
- pts = fp .rack .points ()
569
- pol = Wire (makePolygon (list (map (fcvec , pts ))))
570
-
571
- if fp .height .Value == 0 :
616
+ teeth [- 1 ] = Wire (teeth [- 1 ].Edges [:- 1 ])
617
+
618
+ if obj .add_endings :
619
+ teeth = [Wire (tooth_edges [0 ])] + teeth
620
+ last_edge = tooth_edges [- 1 ]
621
+ last_edge .translate (App .Vector (0 , np .pi * m * (obj .teeth - 1 ), 0 ))
622
+ teeth = teeth + [Wire (last_edge )]
623
+
624
+ p_start = np .array (teeth [0 ].Edges [0 ].firstVertex ().Point [:- 1 ])
625
+ p_end = np .array (teeth [- 1 ].Edges [- 1 ].lastVertex ().Point [:- 1 ])
626
+ p_start_1 = p_start - np .array ([obj .thickness .Value , 0. ])
627
+ p_end_1 = p_end - np .array ([obj .thickness .Value , 0. ])
628
+
629
+ line6 = [p_start , p_start_1 ]
630
+ line7 = [p_start_1 , p_end_1 ]
631
+ line8 = [p_end_1 , p_end ]
632
+
633
+ bottom = points_to_wire ([line6 , line7 , line8 ])
634
+
635
+ pol = Wire ([bottom ] + teeth )
636
+
637
+ if obj .height .Value == 0 :
572
638
return pol
573
- elif fp .beta .Value == 0 :
639
+ elif obj .beta .Value == 0 :
574
640
face = Face (Wire (pol ))
575
- return face .extrude (fcvec ([0. , 0. , fp .height .Value ]))
576
- elif fp .double_helix :
577
- beta = fp .beta .Value * np .pi / 180.
641
+ return face .extrude (fcvec ([0. , 0. , obj .height .Value ]))
642
+ elif obj .double_helix :
643
+ beta = obj .beta .Value * np .pi / 180.
578
644
pol2 = Part .Wire (pol )
579
645
pol2 .translate (
580
- fcvec ([0. , np .tan (beta ) * fp .height .Value / 2 , fp .height .Value / 2 ]))
646
+ fcvec ([0. , np .tan (beta ) * obj .height .Value / 2 , obj .height .Value / 2 ]))
581
647
pol3 = Part .Wire (pol )
582
- pol3 .translate (fcvec ([0. , 0. , fp .height .Value ]))
648
+ pol3 .translate (fcvec ([0. , 0. , obj .height .Value ]))
583
649
return makeLoft ([pol , pol2 , pol3 ], True , True )
584
650
else :
585
- beta = fp .beta .Value * np .pi / 180.
651
+ beta = obj .beta .Value * np .pi / 180.
586
652
pol2 = Part .Wire (pol )
587
653
pol2 .translate (
588
- fcvec ([0. , np .tan (beta ) * fp .height .Value , fp .height .Value ]))
654
+ fcvec ([0. , np .tan (beta ) * obj .height .Value , obj .height .Value ]))
589
655
return makeLoft ([pol , pol2 ], True )
590
656
591
657
def __getstate__ (self ):
0 commit comments