Skip to content

Commit

Permalink
do code cleanup
Browse files Browse the repository at this point in the history
move BOPTools from Part to PartGui because it depends on GUI
  • Loading branch information
wwmayer committed Mar 1, 2017
1 parent 4664e5b commit 02fb687
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
16 changes: 0 additions & 16 deletions src/Mod/Part/App/AppPart.cpp
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions src/Mod/Part/InitGui.py
Expand Up @@ -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)))

Expand Down

0 comments on commit 02fb687

Please sign in to comment.