Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8db1141a57 | ||
|
|
b1e1d7467d | ||
|
|
c44738a6f6 | ||
|
|
f3ec22f524 | ||
|
|
1b46e4b39a | ||
|
|
62909966f2 | ||
|
|
ecc42b23ca | ||
|
|
00d814e8bd | ||
|
|
ab50047800 | ||
|
|
23f8dbaf19 | ||
|
|
a511a2835d | ||
|
|
ff1fe8bdb3 | ||
|
|
f68653d442 | ||
|
|
4c7f5410b0 | ||
|
|
6abbeb1fef | ||
|
|
146767418a | ||
|
|
97df5a8077 | ||
|
|
5fc6b813e3 | ||
|
|
25aafca940 |
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
recursive-include freecad_gear/freecad/icons *
|
||||||
7
freecad_gear/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/lib/python
|
||||||
|
|
||||||
|
from freecad_gear.gearfunc._involute_tooth import involute_rack, involute_tooth
|
||||||
|
from freecad_gear.gearfunc._cycloide_tooth import cycloide_tooth
|
||||||
|
from freecad_gear.gearfunc._bevel_tooth import bevel_tooth
|
||||||
|
|
||||||
|
import freecad_gear.freecad
|
||||||
143
freecad_gear/freecad/__init__.py
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
#***************************************************************************
|
||||||
|
#* *
|
||||||
|
#* This program is free software; you can redistribute it and/or modify *
|
||||||
|
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||||
|
#* as published by the Free Software Foundation; either version 2 of *
|
||||||
|
#* the License, or (at your option) any later version. *
|
||||||
|
#* for detail see the LICENCE text file. *
|
||||||
|
#* *
|
||||||
|
#* This program is distributed in the hope that it will be useful, *
|
||||||
|
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
#* GNU Library General Public License for more details. *
|
||||||
|
#* *
|
||||||
|
#* You should have received a copy of the GNU Library General Public *
|
||||||
|
#* License along with this program; if not, write to the Free Software *
|
||||||
|
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||||
|
#* USA *
|
||||||
|
#* *
|
||||||
|
#***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
from PySide import QtGui, QtCore
|
||||||
|
|
||||||
|
freecad_found = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
import FreeCADGui as Gui
|
||||||
|
import Part
|
||||||
|
import FreeCAD as App
|
||||||
|
except ImportError:
|
||||||
|
freecad_found = False
|
||||||
|
|
||||||
|
if freecad_found:
|
||||||
|
|
||||||
|
import freecad_gear as gear
|
||||||
|
from freecad_gear.freecad.commands import (createInvoluteGear,
|
||||||
|
createCycloidGear, createBevelGear, createInvoluteRack)
|
||||||
|
|
||||||
|
|
||||||
|
class gearToolBox(object):
|
||||||
|
def __init__(self):
|
||||||
|
mw = Gui.getMainWindow()
|
||||||
|
[
|
||||||
|
self.involuteGearAction,
|
||||||
|
self.involuteRackAction,
|
||||||
|
self.bevelGearAction,
|
||||||
|
self.cycloidGearAction,
|
||||||
|
self.dropdown_action] = [None, None, None, None, None]
|
||||||
|
self.defaultAction = createInvoluteGear
|
||||||
|
self.add_gear_wb()
|
||||||
|
mw.workbenchActivated.connect(self.add_gear_wb)
|
||||||
|
timer = mw.findChild(QtCore.QTimer, "activityTimer")
|
||||||
|
timer.connect(timer, QtCore.SIGNAL("timeout()"), self.checkDocument)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def add_gear_wb(self, *args):
|
||||||
|
print("Workbench_changed")
|
||||||
|
try:
|
||||||
|
wb = Gui.activeWorkbench()
|
||||||
|
except Exception as e:
|
||||||
|
return
|
||||||
|
|
||||||
|
if "PartWorkbench" in str(wb):
|
||||||
|
|
||||||
|
mainWindow = Gui.getMainWindow()
|
||||||
|
|
||||||
|
# add the module to Freecad
|
||||||
|
try:
|
||||||
|
if Gui.gear.gear_toolbar:
|
||||||
|
Gui.gear.gear_toolbar.show()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
Gui.gear = gear.__class__("gear")
|
||||||
|
print(type(gear))
|
||||||
|
|
||||||
|
# create toolbar
|
||||||
|
Gui.gear.gear_toolbar = mainWindow.addToolBar("Part: GearToolbar")
|
||||||
|
Gui.gear.gear_toolbar.setObjectName("GearToolbar")
|
||||||
|
|
||||||
|
this_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self.dropdown = QtGui.QMenu("gear_menu", Gui.gear.gear_toolbar)
|
||||||
|
|
||||||
|
# create commands
|
||||||
|
icon = QtGui.QIcon(this_path + "/icons/involutegear.svg")
|
||||||
|
self.involuteGearAction = QtGui.QAction(icon, "involute gear", self.dropdown)
|
||||||
|
self.involuteGearAction.setObjectName("GearToolbar")
|
||||||
|
self.involuteGearAction.triggered.connect(
|
||||||
|
self.set_default_action(self.involuteGearAction, createInvoluteGear))
|
||||||
|
|
||||||
|
icon = QtGui.QIcon(this_path + "/icons/involuterack.svg")
|
||||||
|
self.involuteRackAction = QtGui.QAction(icon, "involute rack", self.dropdown)
|
||||||
|
self.involuteRackAction.setObjectName("GearToolbar")
|
||||||
|
self.involuteRackAction.triggered.connect(
|
||||||
|
self.set_default_action(self.involuteRackAction, createInvoluteRack))
|
||||||
|
|
||||||
|
icon = QtGui.QIcon(this_path + "/icons/cycloidegear.svg")
|
||||||
|
self.cycloidGearAction = QtGui.QAction(icon, "cycloid gear", self.dropdown)
|
||||||
|
self.cycloidGearAction.setObjectName("GearToolbar")
|
||||||
|
self.cycloidGearAction.triggered.connect(
|
||||||
|
self.set_default_action(self.cycloidGearAction, createCycloidGear))
|
||||||
|
|
||||||
|
icon = QtGui.QIcon(this_path + "/icons/bevelgear.svg")
|
||||||
|
self.bevelGearAction = QtGui.QAction(icon, "bevel gear", self.dropdown)
|
||||||
|
self.bevelGearAction.setObjectName("GearToolbar")
|
||||||
|
self.bevelGearAction.triggered.connect(
|
||||||
|
self.set_default_action(self.bevelGearAction, createBevelGear))
|
||||||
|
|
||||||
|
|
||||||
|
temp1 = self.dropdown.addAction(self.involuteGearAction)
|
||||||
|
temp2 = self.dropdown.addAction(self.involuteRackAction)
|
||||||
|
temp3 = self.dropdown.addAction(self.cycloidGearAction)
|
||||||
|
temp4 = self.dropdown.addAction(self.bevelGearAction)
|
||||||
|
|
||||||
|
self.dropdown.setIcon(self.involuteGearAction.icon())
|
||||||
|
temp5 = Gui.gear.gear_toolbar.addAction(self.dropdown.menuAction())
|
||||||
|
self.checkDocument()
|
||||||
|
|
||||||
|
self.defaultCommand = createInvoluteGear
|
||||||
|
self.dropdown.menuAction().triggered.connect(self.defaultCommand)
|
||||||
|
|
||||||
|
def set_default_action(self, action, command):
|
||||||
|
def cb(*args):
|
||||||
|
self.dropdown.setIcon(action.icon())
|
||||||
|
self.defaultCommand = command
|
||||||
|
command()
|
||||||
|
return cb
|
||||||
|
|
||||||
|
def checkDocument(self, *args):
|
||||||
|
enable = False
|
||||||
|
if App.ActiveDocument:
|
||||||
|
enable = True
|
||||||
|
for action in [self.involuteGearAction, self.involuteRackAction,
|
||||||
|
self.bevelGearAction, self.cycloidGearAction, self.dropdown.menuAction()]:
|
||||||
|
if action:
|
||||||
|
action.setEnabled(enable)
|
||||||
|
|
||||||
|
if freecad_found:
|
||||||
|
a = gearToolBox()
|
||||||
@@ -18,37 +18,35 @@
|
|||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
|
import FreeCAD as App
|
||||||
import FreeCADGui as Gui
|
import FreeCADGui as Gui
|
||||||
import FreeCAD
|
from freecad_gear.gearfunc._Classes import involute_gear, cycloide_gear, bevel_gear, involute_gear_rack
|
||||||
import gear_rc
|
|
||||||
|
|
||||||
|
|
||||||
class gearWorkbench(Workbench):
|
def createInvoluteGear(*args):
|
||||||
"""glider workbench"""
|
a = App.ActiveDocument.addObject("Part::FeaturePython", "involute_gear")
|
||||||
MenuText = "gear"
|
involute_gear(a)
|
||||||
ToolTip = "gear workbench"
|
a.ViewObject.Proxy = 0.
|
||||||
Icon = "gearworkbench.svg"
|
App.ActiveDocument.recompute()
|
||||||
|
Gui.SendMsgToActiveView("ViewFit")
|
||||||
|
|
||||||
def GetClassName(self):
|
def createInvoluteRack(*args):
|
||||||
return "Gui::PythonWorkbench"
|
a = App.ActiveDocument.addObject("Part::FeaturePython", "involute_gear")
|
||||||
|
involute_gear_rack(a)
|
||||||
|
a.ViewObject.Proxy = 0.
|
||||||
|
App.ActiveDocument.recompute()
|
||||||
|
Gui.SendMsgToActiveView("ViewFit")
|
||||||
|
|
||||||
def Initialize(self):
|
def createBevelGear(*args):
|
||||||
|
a = App.ActiveDocument.addObject("Part::FeaturePython", "bevel_gear")
|
||||||
|
bevel_gear(a)
|
||||||
|
a.ViewObject.Proxy = 0.
|
||||||
|
App.ActiveDocument.recompute()
|
||||||
|
Gui.SendMsgToActiveView("ViewFit")
|
||||||
|
|
||||||
from gearfunc import CreateCycloideGear, CreateInvoluteGear, CreateBevelGear, CreateInvoluteRack
|
def createCycloidGear(*args):
|
||||||
|
a = App.ActiveDocument.addObject("Part::FeaturePython", "cycloide_gear")
|
||||||
self.appendToolbar("Gear", ["CreateInvoluteGear", "CreateInvoluteRack", "CreateCycloideGear", "CreateBevelGear"])
|
cycloide_gear(a)
|
||||||
self.appendMenu("Gear", ["CreateInvoluteGear", "CreateInvoluteRack", "CreateCycloideGear","CreateBevelGear"])
|
a.ViewObject.Proxy = 0.
|
||||||
Gui.addIconPath(FreeCAD.getHomePath()+"Mod/gear/icons/")
|
App.ActiveDocument.recompute()
|
||||||
Gui.addCommand('CreateInvoluteGear', CreateInvoluteGear())
|
Gui.SendMsgToActiveView("ViewFit")
|
||||||
Gui.addCommand('CreateCycloideGear', CreateCycloideGear())
|
|
||||||
Gui.addCommand('CreateBevelGear', CreateBevelGear())
|
|
||||||
Gui.addCommand('CreateInvoluteRack', CreateInvoluteRack())
|
|
||||||
|
|
||||||
def Activated(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def Deactivated(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
Gui.addWorkbench(gearWorkbench())
|
|
||||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 145 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
0
freecad_gear/gearfunc/__init__.py
Normal file
@@ -1,9 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource>
|
|
||||||
<file>icons/gearworkbench.svg</file>
|
|
||||||
<file>icons/involutegear.svg</file>
|
|
||||||
<file>icons/cycloidegear.svg</file>
|
|
||||||
<file>icons/involuterack.svg</file>
|
|
||||||
<file>icons/bevelgear.svg</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource>
|
|
||||||
<file>icons/gearworkbench.svg</file>
|
|
||||||
<file>icons/involutegear.svg</file>
|
|
||||||
<file>icons/cycloidegear.svg</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#!/usr/lib/python
|
|
||||||
|
|
||||||
from gearfunc._involute_tooth import involute_rack, involute_tooth
|
|
||||||
from gearfunc._cycloide_tooth import cycloide_tooth
|
|
||||||
from gearfunc._bevel_tooth import bevel_tooth
|
|
||||||
from gearfunc import CreateInvoluteRack, CreateCycloideGear, CreateInvoluteGear, CreateBevelGear
|
|
||||||
|
|
||||||
from tests import bspline_surf
|
|
||||||
|
|
||||||
|
|
||||||
__All__ = [
|
|
||||||
"CreateInvoluteRack",
|
|
||||||
"CreateCycloideGear",
|
|
||||||
"CreateInvoluteGear",
|
|
||||||
"CreateBevelGear",
|
|
||||||
"involute_rack",
|
|
||||||
"involute_tooth",
|
|
||||||
"bevel_tooth"
|
|
||||||
]
|
|
||||||
|
|
||||||
12892
gear/gear_rc.py
@@ -1,108 +0,0 @@
|
|||||||
#***************************************************************************
|
|
||||||
#* *
|
|
||||||
#* This program is free software; you can redistribute it and/or modify *
|
|
||||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
|
||||||
#* as published by the Free Software Foundation; either version 2 of *
|
|
||||||
#* the License, or (at your option) any later version. *
|
|
||||||
#* for detail see the LICENCE text file. *
|
|
||||||
#* *
|
|
||||||
#* This program is distributed in the hope that it will be useful, *
|
|
||||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
#* GNU Library General Public License for more details. *
|
|
||||||
#* *
|
|
||||||
#* You should have received a copy of the GNU Library General Public *
|
|
||||||
#* License along with this program; if not, write to the Free Software *
|
|
||||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
|
||||||
#* USA *
|
|
||||||
#* *
|
|
||||||
#***************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
import FreeCAD
|
|
||||||
import FreeCADGui as Gui
|
|
||||||
from _Classes import involute_gear, cycloide_gear, bevel_gear, involute_gear_rack
|
|
||||||
|
|
||||||
|
|
||||||
class CreateInvoluteGear():
|
|
||||||
"""create an involute gear"""
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def GetResources(self):
|
|
||||||
return {'Pixmap': 'involutegear.svg', 'MenuText': 'involute gear', 'ToolTip': 'involute gear'}
|
|
||||||
|
|
||||||
def IsActive(self):
|
|
||||||
if FreeCAD.ActiveDocument is None:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def Activated(self):
|
|
||||||
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "involute_gear")
|
|
||||||
involute_gear(a)
|
|
||||||
a.ViewObject.Proxy = 0.
|
|
||||||
FreeCAD.ActiveDocument.recompute()
|
|
||||||
Gui.SendMsgToActiveView("ViewFit")
|
|
||||||
|
|
||||||
|
|
||||||
class CreateInvoluteRack():
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def GetResources(self):
|
|
||||||
return {'Pixmap': 'involuterack.svg', 'MenuText': 'involute rack', 'ToolTip': 'involute rack'}
|
|
||||||
|
|
||||||
def IsActive(self):
|
|
||||||
if FreeCAD.ActiveDocument is None:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def Activated(self):
|
|
||||||
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "involute_rack")
|
|
||||||
involute_gear_rack(a)
|
|
||||||
a.ViewObject.Proxy = 0.
|
|
||||||
FreeCAD.ActiveDocument.recompute()
|
|
||||||
Gui.SendMsgToActiveView("ViewFit")
|
|
||||||
|
|
||||||
|
|
||||||
class CreateCycloideGear():
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def GetResources(self):
|
|
||||||
return {'Pixmap': 'cycloidegear.svg', 'MenuText': 'cycloide gear', 'ToolTip': 'cycloide gear'}
|
|
||||||
|
|
||||||
def IsActive(self):
|
|
||||||
if FreeCAD.ActiveDocument is None:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def Activated(self):
|
|
||||||
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "cycloide_gear")
|
|
||||||
cycloide_gear(a)
|
|
||||||
a.ViewObject.Proxy = 0.
|
|
||||||
FreeCAD.ActiveDocument.recompute()
|
|
||||||
Gui.SendMsgToActiveView("ViewFit")
|
|
||||||
|
|
||||||
class CreateBevelGear():
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def GetResources(self):
|
|
||||||
return {'Pixmap': 'bevelgear.svg', 'MenuText': 'bevel gear', 'ToolTip': 'bevel gear'}
|
|
||||||
|
|
||||||
def IsActive(self):
|
|
||||||
if FreeCAD.ActiveDocument is None:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def Activated(self):
|
|
||||||
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "bevel_gear")
|
|
||||||
bevel_gear(a)
|
|
||||||
a.ViewObject.Proxy = 0.
|
|
||||||
FreeCAD.ActiveDocument.recompute()
|
|
||||||
Gui.SendMsgToActiveView("ViewFit")
|
|
||||||
18
setup.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name = 'freecad_gear',
|
||||||
|
version = '0.3',
|
||||||
|
packages = ["freecad_gear", "freecad_gear/freecad/", "freecad_gear/gearfunc/"],
|
||||||
|
include_package_data=True,
|
||||||
|
description = 'Some gears for freecad',
|
||||||
|
author = 'Lorenz L',
|
||||||
|
author_email = 'sppedflyer@gmail.com',
|
||||||
|
url = 'https://github.com/looooo/FCGear',
|
||||||
|
download_url = 'https://github.com/looooo/FCGear/tarball/0.3',
|
||||||
|
keywords = ['gear', 'freecad'],
|
||||||
|
classifiers = [],
|
||||||
|
)
|
||||||