16
16
# * *
17
17
# ***************************************************************************
18
18
19
- from pygears import __version__
20
19
import os
20
+ import copy
21
+ import numpy as np
22
+ import FreeCAD
23
+ from pygears import __version__
24
+ from .features import InvoluteGear
21
25
22
26
class ViewProviderGearConnector (object ):
23
27
def __init__ (self , vobj , icon_fn = None ):
@@ -33,7 +37,7 @@ def getIcon(self):
33
37
return self .icon_fn
34
38
35
39
def claimChildren (self ):
36
- return [self .vobj .Object .master_gear , self .vobj .Object .slave_gear ]
40
+ return [self .vobj .Object .master_gear , self .vobj .Object .slave_gear ]
37
41
38
42
def __getstate__ (self ):
39
43
return {"icon_fn" : self .icon_fn }
@@ -47,9 +51,37 @@ def __init__(self, obj, master_gear, slave_gear):
47
51
obj .addProperty ("App::PropertyString" , "version" , "version" , "freecad.gears-version" , 1 )
48
52
obj .addProperty ("App::PropertyLink" ,"master_gear" ,"gear" ,"master gear" , 1 )
49
53
obj .addProperty ("App::PropertyLink" ,"slave_gear" ,"gear" ,"slave gear" , 1 )
54
+ obj .addProperty ("App::PropertyAngle" , "angle1" , "gear" , "angle at which second gear is placed" , 0 )
55
+ obj .addProperty ("App::PropertyAngle" , "angle2" , "gear" , "angle at which second gear is placed" , 0 )
50
56
obj .version = __version__
51
57
obj .master_gear = master_gear
52
58
obj .slave_gear = slave_gear
59
+ obj .angle1 = 0
60
+ obj .angle2 = 0
61
+ obj .Proxy = self
62
+
63
+ def onChanged (self , fp , prop ):
64
+ print (fp .master_gear .Proxy )
65
+ if isinstance (fp .master_gear .Proxy , InvoluteGear ) and isinstance (fp .slave_gear .Proxy , InvoluteGear ):
66
+ fp .master_gear .Placement .Rotation .Angle = np .deg2rad (fp .angle2 .Value )
67
+ angle_master = fp .master_gear .Placement .Rotation .Angle
68
+ dw_master = fp .master_gear .dw
69
+ dw_slave = fp .slave_gear .dw
70
+ mat0 = FreeCAD .Matrix () # unity matrix
71
+ trans = FreeCAD .Vector (dw_master + dw_slave ) / 2
72
+ mat0 .move (trans )
73
+ rot = FreeCAD .Rotation (FreeCAD .Vector (0 ,0 ,1 ), fp .angle1 ).toMatrix ()
74
+ angle2 = dw_master / dw_slave * fp .angle1 .Value
75
+ angle4 = dw_master / dw_slave * np .rad2deg (angle_master )
76
+ rot2 = FreeCAD .Rotation (FreeCAD .Vector (0 ,0 ,1 ), angle2 ).toMatrix ()
77
+ angle3 = abs (fp .slave_gear .teeth % 2 - 1 ) * 180. / fp .slave_gear .teeth
78
+ rot3 = FreeCAD .Rotation (FreeCAD .Vector (0 ,0 ,1 ), angle3 ).toMatrix ()
79
+ rot4 = FreeCAD .Rotation (FreeCAD .Vector (0 ,0 ,1 ), - angle4 ).toMatrix ()
80
+ mat1 = rot * mat0 * rot2 * rot3 * rot4
81
+ mat1 .move (fp .master_gear .Placement .Base )
82
+ fp .slave_gear .Placement = mat1
83
+
84
+
85
+
86
+
53
87
54
- def execute (self , fp ):
55
- pass
0 commit comments