Skip to content

Commit ea904a2

Browse files
committed
add prototype for gear connector
1 parent 0eca70d commit ea904a2

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

freecad/gears/commands.py

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import FreeCADGui as Gui
2222
from .features import ViewProviderGear, InvoluteGear, InternalInvoluteGear, InvoluteGearRack, CycloidGearRack
2323
from .features import CycloidGear, BevelGear, CrownGear, WormGear, TimingGear, LanternGear, HypoCycloidGear
24+
from .connector import GearConnector, ViewProviderGearConnector
2425

2526

2627
class BaseCommand(object):
@@ -157,3 +158,19 @@ class CreateLanternGear(BaseCommand):
157158
Pixmap = os.path.join(BaseCommand.ICONDIR, 'lanterngear.svg')
158159
MenuText = 'Lantern gear'
159160
ToolTip = 'Create a Lantern gear'
161+
162+
class CreateGearConnector(BaseCommand):
163+
NAME = "gearconnector"
164+
GEAR_FUNCTION = GearConnector
165+
Pixmap = os.path.join(BaseCommand.ICONDIR, 'gearconnector.svg')
166+
MenuText = 'Combine two gears'
167+
ToolTip = 'Combine two gears'
168+
169+
def Activated(self):
170+
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", self.NAME)
171+
gear1 = Gui.Selection.getSelection()[0]
172+
gear2 = Gui.Selection.getSelection()[1]
173+
# check if selected objects are beams
174+
GearConnector(obj, gear1, gear2)
175+
ViewProviderGearConnector(obj.ViewObject)
176+
return obj

freecad/gears/features.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def fcvec(x):
5555

5656
class ViewProviderGear(object):
5757
def __init__(self, obj, icon_fn=None):
58-
''' Set this object to the proxy object of the actual view provider '''
58+
# Set this object to the proxy object of the actual view provider
5959
obj.Proxy = self
6060
self._check_attr()
6161
dirname = os.path.dirname(__file__)

freecad/gears/init_gui.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class GearWorkbench(Workbench):
4646
"CreateWormGear",
4747
"CreateTimingGear",
4848
"CreateLanternGear",
49-
"CreateHypoCycloidGear"]
49+
"CreateHypoCycloidGear",
50+
"CreateGearConnector"]
5051

5152
def GetClassName(self):
5253
return "Gui::PythonWorkbench"
@@ -56,6 +57,7 @@ def Initialize(self):
5657
from .commands import CreateBevelGear, CreateInvoluteRack, CreateCrownGear
5758
from .commands import CreateWormGear, CreateTimingGear, CreateLanternGear
5859
from .commands import CreateHypoCycloidGear, CreateCycloidRack
60+
from .commands import CreateGearConnector
5961

6062
self.appendToolbar("Gear", self.commands)
6163
self.appendMenu("Gear", self.commands)
@@ -71,6 +73,7 @@ def Initialize(self):
7173
Gui.addCommand('CreateTimingGear', CreateTimingGear())
7274
Gui.addCommand('CreateLanternGear', CreateLanternGear())
7375
Gui.addCommand('CreateHypoCycloidGear', CreateHypoCycloidGear())
76+
Gui.addCommand('CreateGearConnector', CreateGearConnector())
7477

7578
def Activated(self):
7679
pass

0 commit comments

Comments
 (0)