PD: Fix error "duplicate command PartDesign_InvoluteGear"
Every time the InvoluteGearFeature python module was imported, and we're in GUI context, the command "PartDesign_InvoluteGear" was registered. On the 2nd (3rd, ...) time, this was reported as an error in the console, like "error: Command.cpp(1841): duplicate command PartDesign_InvoluteGear" The first import happens when the PartDesign FreeCAD Module is loaded, via `InitGui.py`. Subsequent imports may happen when e.g. executing the involute gear command or when running it's tests via FC's Test WB. This change now registers the command only then the PartDesign WB is set up in InitGui, not when importing the python module. The same fix is applied for sprocket, where the same pattern for command registration was used. In addition, the import error catch was removed, which seems to be a copy paste left-over from the ShaftWizard. In contrast to ShaftWizard, involute gear and sprocket only use modules from the Python standard lib, so I think this precaution is not worth the additional complexity, just for hiding actual errors.
This commit is contained in:
@@ -452,14 +452,12 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
<< "Separator"
|
||||
<< "Part_CheckGeometry"
|
||||
<< "Separator"
|
||||
<< "PartDesign_InvoluteGear"
|
||||
<< "PartDesign_Sprocket";
|
||||
|
||||
// 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_InvoluteGear")) {
|
||||
*part << "PartDesign_InvoluteGear";
|
||||
}
|
||||
if (Gui::Application::Instance->commandManager().getCommandByName("PartDesign_WizardShaft")) {
|
||||
*part << "Separator" << "PartDesign_WizardShaft";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user