diff --git a/src/Mod/PartDesign/CMakeLists.txt b/src/Mod/PartDesign/CMakeLists.txt index a189626c9..5a5821da0 100644 --- a/src/Mod/PartDesign/CMakeLists.txt +++ b/src/Mod/PartDesign/CMakeLists.txt @@ -31,12 +31,13 @@ INSTALL( SET(WizardShaft_SRCS WizardShaft/__init__.py - WizardShaft/WizardShaft.py - WizardShaft/WizardShaftTable.py - WizardShaft/Shaft.py - WizardShaft/ShaftFeature.py - WizardShaft/ShaftDiagram.py - WizardShaft/SegmentFunction.py + WizardShaft/WizardShaft.svg + WizardShaft/WizardShaft.py + WizardShaft/WizardShaftTable.py + WizardShaft/Shaft.py + WizardShaft/ShaftFeature.py + WizardShaft/ShaftDiagram.py + WizardShaft/SegmentFunction.py ) SOURCE_GROUP("wizardshaft" FILES ${WizardShaft_SRCS}) diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index d1e9b6814..aa374b539 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -28,6 +28,8 @@ #endif #include "Workbench.h" +#include +#include #include #include #include @@ -214,9 +216,13 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "PartDesign_LinearPattern" << "PartDesign_PolarPattern" // << "PartDesign_Scaled" - << "PartDesign_MultiTransform" - << "Separator" - << "PartDesign_WizardShaft"; + << "PartDesign_MultiTransform"; + // For 0.13 a couple of python packages like numpy, matplotlib and others + // are not deployed with the installer on Windows. Thus, the WizardShaft is + // not deployed either hence the check for the existence of the command. + if (Gui::Application::Instance->commandManager().getCommandByName("PartDesign_WizardShaft")) { + *part << "Separator" << "PartDesign_WizardShaft"; + } return root; } diff --git a/src/Mod/PartDesign/InitGui.py b/src/Mod/PartDesign/InitGui.py index 1afa2de53..8b590eafb 100644 --- a/src/Mod/PartDesign/InitGui.py +++ b/src/Mod/PartDesign/InitGui.py @@ -31,7 +31,6 @@ class PartDesignWorkbench ( Workbench ): "PartDesign workbench object" - from WizardShaft import WizardShaft Icon = """ /* XPM */ static char * partdesign_xpm[] = { @@ -67,6 +66,10 @@ class PartDesignWorkbench ( Workbench ): def Initialize(self): # load the module + try: + from WizardShaft import WizardShaft + except: + print "Wizard shaft not installed" import PartDesignGui import PartDesign def GetClassName(self): diff --git a/src/Mod/PartDesign/WizardShaft/Shaft.py b/src/Mod/PartDesign/WizardShaft/Shaft.py index cdff47a3c..78716a126 100644 --- a/src/Mod/PartDesign/WizardShaft/Shaft.py +++ b/src/Mod/PartDesign/WizardShaft/Shaft.py @@ -201,7 +201,11 @@ class Shaft: self.printEquilibrium(variableNames, coefficientsMbz) # Build matrix and vector for linear algebra solving algorithm - import numpy as np + try: + import numpy as np + except ImportError: + FreeCAD.Console.PrintMessage("numpy is not installed on your system\n") + raise ImportError("numpy not installed") if (len(coefficientsFy) < 3) or (len(coefficientsMbz) < 3): return A = np.array([coefficientsFy[1:], coefficientsMbz[1:]]) diff --git a/src/Mod/PartDesign/WizardShaft/WizardShaft.py b/src/Mod/PartDesign/WizardShaft/WizardShaft.py index e2d7aa115..9b5c6a164 100644 --- a/src/Mod/PartDesign/WizardShaft/WizardShaft.py +++ b/src/Mod/PartDesign/WizardShaft/WizardShaft.py @@ -49,7 +49,7 @@ class TaskWizardShaft: # updateSketch() slot will be activated and it relies on finding a valid document if self.doc == None: self.Gui.activateWorkbench("PartDesignWorkbench") - self.doc = self.App.newDocument() + self.doc = self.App.ActiveDocument # Grab the newly created feature window featureWindow = cw.subWindowList()[-1] else: @@ -80,11 +80,14 @@ class WizardShaftGui: FreeCADGui.Control.showDialog(TaskWizardShaft()) def GetResources(self): - IconPath = FreeCAD.ConfigGet("AppHomePath") + "Mod/PartDesign/Gui/Resources/icons/WizardShaftIcon.png" - MenuText = 'Start the shaft design wizard' + IconPath = FreeCAD.ConfigGet("AppHomePath") + "Mod/PartDesign/WizardShaft/WizardShaft.svg" + MenuText = 'Shaft design wizard...' ToolTip = 'Start the shaft design wizard' return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} + def IsActive(self): + return FreeCAD.ActiveDocument != None + FreeCADGui.addCommand('PartDesign_WizardShaft', WizardShaftGui()) #Note: Start wizard in Python Console with diff --git a/src/Mod/PartDesign/WizardShaft/WizardShaft.svg b/src/Mod/PartDesign/WizardShaft/WizardShaft.svg new file mode 100644 index 000000000..d0322fd3b --- /dev/null +++ b/src/Mod/PartDesign/WizardShaft/WizardShaft.svg @@ -0,0 +1,419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + +