From e371d021a23c637651b91e024d7afd3254c1bf73 Mon Sep 17 00:00:00 2001 From: looooo Date: Mon, 23 Nov 2015 18:12:09 +0100 Subject: [PATCH] added symbol --- gearfunc/_Classes.py | 27 +++++++++++++++++++++++++++ gearfunc/__init__.py | 10 +++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/gearfunc/_Classes.py b/gearfunc/_Classes.py index e4cabab..4a1528c 100644 --- a/gearfunc/_Classes.py +++ b/gearfunc/_Classes.py @@ -20,6 +20,7 @@ #*************************************************************************** from __future__ import division +import os import FreeCAD as App from _involute_tooth import involute_tooth, involute_rack from _cycloide_tooth import cycloide_tooth @@ -34,12 +35,38 @@ from numpy import pi, cos, sin, tan import numpy + +__all__=["involute_gear", + "cycloide_gear", + "bevel_gear", + "involute_gear_rack", + "ViewProviderGear"] + + + def fcvec(x): if len(x) == 2: return(App.Vector(x[0], x[1], 0)) else: return(App.Vector(x[0], x[1], x[2])) +class ViewProviderGear: + def __init__(self, obj): + ''' Set this object to the proxy object of the actual view provider ''' + obj.Proxy = self + + def attach(self, vobj): + self.vobj = vobj + + def getIcon(self): + _dir = os.path.dirname(os.path.realpath(__file__)) + return(_dir + "/../Resources/icons/involutegear.svg") + + def __getstate__(self): + return None + + def __setstate__(self, state): + return None class involute_gear(): diff --git a/gearfunc/__init__.py b/gearfunc/__init__.py index 49a2d2e..3fe07f3 100644 --- a/gearfunc/__init__.py +++ b/gearfunc/__init__.py @@ -21,7 +21,7 @@ import FreeCAD import FreeCADGui as Gui -from _Classes import involute_gear, cycloide_gear, bevel_gear, involute_gear_rack +from _Classes import * class CreateInvoluteGear(): @@ -41,7 +41,7 @@ class CreateInvoluteGear(): def Activated(self): a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "involute_gear") involute_gear(a) - a.ViewObject.Proxy = 0. + ViewProviderGear(a.ViewObject) FreeCAD.ActiveDocument.recompute() Gui.SendMsgToActiveView("ViewFit") @@ -62,7 +62,7 @@ class CreateInvoluteRack(): def Activated(self): a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "involute_rack") involute_gear_rack(a) - a.ViewObject.Proxy = 0. + ViewProviderGear(a.ViewObject) FreeCAD.ActiveDocument.recompute() Gui.SendMsgToActiveView("ViewFit") @@ -83,7 +83,7 @@ class CreateCycloideGear(): def Activated(self): a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "cycloide_gear") cycloide_gear(a) - a.ViewObject.Proxy = 0. + ViewProviderGear(a.ViewObject) FreeCAD.ActiveDocument.recompute() Gui.SendMsgToActiveView("ViewFit") @@ -103,6 +103,6 @@ class CreateBevelGear(): def Activated(self): a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "bevel_gear") bevel_gear(a) - a.ViewObject.Proxy = 0. + ViewProviderGear(a.ViewObject) FreeCAD.ActiveDocument.recompute() Gui.SendMsgToActiveView("ViewFit") \ No newline at end of file