From 02fb687844c192d14643c467f2bd3f1ab604b6ae Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 1 Mar 2017 21:58:04 +0100 Subject: [PATCH] do code cleanup move BOPTools from Part to PartGui because it depends on GUI --- src/Mod/Part/App/AppPart.cpp | 16 ---------------- src/Mod/Part/InitGui.py | 7 ++++--- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index f111e19b7088..7702db130ea1 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -383,22 +383,6 @@ PyMOD_INIT_FUNC(Part) Base::Interpreter().addType(&Part::Line2dSegmentPy::Type,geom2dModule,"Line2dSegment"); Base::Interpreter().addType(&Part::Line2dPy::Type,geom2dModule,"Line2d"); Base::Interpreter().addType(&Part::OffsetCurve2dPy::Type,geom2dModule,"OffsetCurve2d"); -#if 0 /* for python3 this isn't working anymore, it's solved by importing the BOPTools - directly. (import BOPTools) */ -// this causes double initialisation of the part modul with python3. - try { - //import all submodules of BOPTools, to make them easy to browse in Py console. - //It's done in this weird manner instead of bt.caMemberFunction("importAll"), - //because the latter crashed when importAll failed with exception. - Base::Interpreter().runString("__import__('BOPTools').importAll()"); - - Py::Object bt = Base::Interpreter().runStringObject("__import__('BOPTools')"); - module.setAttr(std::string("BOPTools"),bt); - } catch (Base::PyException &err){ - Base::Console().Error("Failed to import BOPTools package:\n"); - err.ReportException(); - } -#endif Part::TopoShape ::init(); Part::PropertyPartShape ::init(); diff --git a/src/Mod/Part/InitGui.py b/src/Mod/Part/InitGui.py index 0bed950fb876..277020106565 100644 --- a/src/Mod/Part/InitGui.py +++ b/src/Mod/Part/InitGui.py @@ -41,13 +41,14 @@ def __init__(self): def Initialize(self): # load the module import PartGui - import BOPTools import CompoundTools._CommandCompoundFilter try: - BOPTools.importAll() - BOPTools.addCommands() + bop = __import__("BOPTools") + bop.importAll() + bop.addCommands() + PartGui.BOPTools = bop except Exception as err: FreeCAD.Console.PrintError("Features from BOPTools package cannot be loaded. {err}\n".format(err= str(err)))