diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt index 5b73a1a3be..8379ba9a87 100644 --- a/src/Mod/Path/CMakeLists.txt +++ b/src/Mod/Path/CMakeLists.txt @@ -67,19 +67,19 @@ SET(PathScripts_SRCS PathScripts/PathUtils.py PathScripts/PostUtils.py PathScripts/__init__.py - PathScripts/centroid_post.py - PathScripts/comparams_post.py - PathScripts/dumper_post.py - PathScripts/dynapath_post.py - PathScripts/example_post.py - PathScripts/example_pre.py - PathScripts/linuxcnc_post.py - PathScripts/opensbp_post.py - PathScripts/opensbp_pre.py - PathScripts/phillips_post.py - PathScripts/rml_post.py - PathScripts/slic3r_pre.py - PathScripts/smoothie_post.py + PathScripts/post/centroid_post.py + PathScripts/post/comparams_post.py + PathScripts/post/dumper_post.py + PathScripts/post/dynapath_post.py + PathScripts/post/example_post.py + PathScripts/post/example_pre.py + PathScripts/post/linuxcnc_post.py + PathScripts/post/opensbp_post.py + PathScripts/post/opensbp_pre.py + PathScripts/post/phillips_post.py + PathScripts/post/rml_post.py + PathScripts/post/slic3r_pre.py + PathScripts/post/smoothie_post.py ) diff --git a/src/Mod/Path/Gui/AppPathGuiPy.cpp b/src/Mod/Path/Gui/AppPathGuiPy.cpp index 7aad0b79ab..e7d93835e0 100644 --- a/src/Mod/Path/Gui/AppPathGuiPy.cpp +++ b/src/Mod/Path/Gui/AppPathGuiPy.cpp @@ -83,7 +83,7 @@ private: try { std::string path = App::GetApplication().getHomePath(); - path += "Mod/Path/PathScripts/"; + path += "Mod/Path/PathScripts/post/"; QDir dir1(QString::fromUtf8(path.c_str()), QString::fromLatin1("*_pre.py")); std::string cMacroPath = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro") ->GetASCII("MacroPath",App::Application::getUserMacroDir().c_str()); @@ -150,7 +150,7 @@ private: try { std::string path = App::GetApplication().getHomePath(); - path += "Mod/Path/PathScripts/"; + path += "Mod/Path/PathScripts/post/"; QDir dir1(QString::fromUtf8(path.c_str()), QString::fromLatin1("*_pre.py")); std::string cMacroPath = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro") ->GetASCII("MacroPath",App::Application::getUserMacroDir().c_str()); @@ -226,7 +226,7 @@ private: throw Py::RuntimeError("No object to export"); std::string path = App::GetApplication().getHomePath(); - path += "Mod/Path/PathScripts/"; + path += "Mod/Path/PathScripts/post/"; QDir dir1(QString::fromUtf8(path.c_str()), QString::fromLatin1("*_post.py")); std::string cMacroPath = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro") ->GetASCII("MacroPath",App::Application::getUserMacroDir().c_str()); diff --git a/src/Mod/Path/PathScripts/PathPost.py b/src/Mod/Path/PathScripts/PathPost.py index 240cdd36dc..f1d30f5afa 100644 --- a/src/Mod/Path/PathScripts/PathPost.py +++ b/src/Mod/Path/PathScripts/PathPost.py @@ -27,8 +27,9 @@ from __future__ import print_function import FreeCAD import FreeCADGui -import os import PathScripts.PathLog as PathLog +import PathScripts.PathUtil as PathUtil +import os from PathScripts import PathJob from PathScripts import PathToolController @@ -248,8 +249,9 @@ class CommandPathPost: for obj in job.Group: PathLog.debug("obj: {}".format(obj.Name)) if not isinstance(obj.Proxy, PathToolController.ToolController): - if obj.ToolController.ToolNumber != currTool: - postlist.append(obj.ToolController) + tc = PathUtil.toolControllerForOp(obj) + if tc.ToolNumber != currTool: + postlist.append(tc) postlist.append(obj) fail = True diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py index 0765780c5d..dd2d75ca15 100644 --- a/src/Mod/Path/PathScripts/PathPreferences.py +++ b/src/Mod/Path/PathScripts/PathPreferences.py @@ -51,6 +51,10 @@ class PathPreferences: def pathScriptsSourcePath(cls): return FreeCAD.getHomePath() + ("Mod/Path/PathScripts/") + @classmethod + def pathScriptsPostSourcePath(cls): + return cls.pathScriptsSourcePath() + ("/post/") + @classmethod def allAvailablePostProcessors(cls): allposts = [] @@ -108,6 +112,7 @@ class PathPreferences: if p: paths.append(p) paths.append(cls.macroFilePath()) + paths.append(cls.pathScriptsPostSourcePath()) paths.append(cls.pathScriptsSourcePath()) return paths diff --git a/src/Mod/Path/PathScripts/PathUtil.py b/src/Mod/Path/PathScripts/PathUtil.py index e730297c57..cff2c0230c 100644 --- a/src/Mod/Path/PathScripts/PathUtil.py +++ b/src/Mod/Path/PathScripts/PathUtil.py @@ -47,3 +47,10 @@ def isValidBaseObject(obj): if hasattr(obj, 'Sheets') or hasattr(obj, 'TagText'): # Arch.Panels and Arch.PanelCut return False return True + +def toolControllerForOp(op): + if hasattr(op, 'ToolController'): + return op.ToolController + if hasattr(op, 'Base'): + return toolControllerForOp(op.Base) + return None diff --git a/src/Mod/Path/PathScripts/centroid_post.py b/src/Mod/Path/PathScripts/post/centroid_post.py similarity index 100% rename from src/Mod/Path/PathScripts/centroid_post.py rename to src/Mod/Path/PathScripts/post/centroid_post.py diff --git a/src/Mod/Path/PathScripts/comparams_post.py b/src/Mod/Path/PathScripts/post/comparams_post.py similarity index 100% rename from src/Mod/Path/PathScripts/comparams_post.py rename to src/Mod/Path/PathScripts/post/comparams_post.py diff --git a/src/Mod/Path/PathScripts/dumper_post.py b/src/Mod/Path/PathScripts/post/dumper_post.py similarity index 100% rename from src/Mod/Path/PathScripts/dumper_post.py rename to src/Mod/Path/PathScripts/post/dumper_post.py diff --git a/src/Mod/Path/PathScripts/dynapath_post.py b/src/Mod/Path/PathScripts/post/dynapath_post.py similarity index 100% rename from src/Mod/Path/PathScripts/dynapath_post.py rename to src/Mod/Path/PathScripts/post/dynapath_post.py diff --git a/src/Mod/Path/PathScripts/example_post.py b/src/Mod/Path/PathScripts/post/example_post.py similarity index 100% rename from src/Mod/Path/PathScripts/example_post.py rename to src/Mod/Path/PathScripts/post/example_post.py diff --git a/src/Mod/Path/PathScripts/example_pre.py b/src/Mod/Path/PathScripts/post/example_pre.py similarity index 100% rename from src/Mod/Path/PathScripts/example_pre.py rename to src/Mod/Path/PathScripts/post/example_pre.py diff --git a/src/Mod/Path/PathScripts/linuxcnc_post.py b/src/Mod/Path/PathScripts/post/linuxcnc_post.py similarity index 100% rename from src/Mod/Path/PathScripts/linuxcnc_post.py rename to src/Mod/Path/PathScripts/post/linuxcnc_post.py diff --git a/src/Mod/Path/PathScripts/opensbp_post.py b/src/Mod/Path/PathScripts/post/opensbp_post.py similarity index 100% rename from src/Mod/Path/PathScripts/opensbp_post.py rename to src/Mod/Path/PathScripts/post/opensbp_post.py diff --git a/src/Mod/Path/PathScripts/opensbp_pre.py b/src/Mod/Path/PathScripts/post/opensbp_pre.py similarity index 100% rename from src/Mod/Path/PathScripts/opensbp_pre.py rename to src/Mod/Path/PathScripts/post/opensbp_pre.py diff --git a/src/Mod/Path/PathScripts/phillips_post.py b/src/Mod/Path/PathScripts/post/phillips_post.py similarity index 100% rename from src/Mod/Path/PathScripts/phillips_post.py rename to src/Mod/Path/PathScripts/post/phillips_post.py diff --git a/src/Mod/Path/PathScripts/rml_post.py b/src/Mod/Path/PathScripts/post/rml_post.py similarity index 100% rename from src/Mod/Path/PathScripts/rml_post.py rename to src/Mod/Path/PathScripts/post/rml_post.py diff --git a/src/Mod/Path/PathScripts/slic3r_pre.py b/src/Mod/Path/PathScripts/post/slic3r_pre.py similarity index 100% rename from src/Mod/Path/PathScripts/slic3r_pre.py rename to src/Mod/Path/PathScripts/post/slic3r_pre.py diff --git a/src/Mod/Path/PathScripts/smoothie_post.py b/src/Mod/Path/PathScripts/post/smoothie_post.py similarity index 100% rename from src/Mod/Path/PathScripts/smoothie_post.py rename to src/Mod/Path/PathScripts/post/smoothie_post.py