Moved post processing files into new Path python module

This commit is contained in:
Markus Lampert
2022-08-10 19:03:14 -07:00
parent 8c05a46174
commit 1d27fb00ec
56 changed files with 127 additions and 116 deletions

View File

@@ -40,6 +40,49 @@ SET(PathPythonOpGui_SRCS
Path/Op/Gui/Adaptive.py
)
SET(PathPythonPost_SRCS
Path/Post/__init__.py
Path/Post/Command.py
Path/Post/Processor.py
Path/Post/Utils.py
Path/Post/UtilsArguments.py
Path/Post/UtilsExport.py
Path/Post/UtilsParse.py
)
SET(PathPythonPostScripts_SRCS
Path/Post/scripts/__init__.py
Path/Post/scripts/centroid_post.py
Path/Post/scripts/comparams_post.py
Path/Post/scripts/dxf_post.py
Path/Post/scripts/dynapath_post.py
Path/Post/scripts/example_pre.py
Path/Post/scripts/fablin_post.py
Path/Post/scripts/fanuc_post.py
Path/Post/scripts/gcode_pre.py
Path/Post/scripts/grbl_post.py
Path/Post/scripts/heidenhain_post.py
Path/Post/scripts/jtech_post.py
Path/Post/scripts/KineticNCBeamicon2_post.py
Path/Post/scripts/linuxcnc_post.py
Path/Post/scripts/mach3_mach4_post.py
Path/Post/scripts/marlin_post.py
Path/Post/scripts/nccad_post.py
Path/Post/scripts/opensbp_post.py
Path/Post/scripts/opensbp_pre.py
Path/Post/scripts/philips_post.py
Path/Post/scripts/refactored_centroid_post.py
Path/Post/scripts/refactored_grbl_post.py
Path/Post/scripts/refactored_linuxcnc_post.py
Path/Post/scripts/refactored_mach3_mach4_post.py
Path/Post/scripts/refactored_test_post.py
Path/Post/scripts/rml_post.py
Path/Post/scripts/rrf_post.py
Path/Post/scripts/slic3r_pre.py
Path/Post/scripts/smoothie_post.py
Path/Post/scripts/uccnc_post.py
)
SET(PathScripts_SRCS
PathScripts/drillableLib.py
PathScripts/PathAreaOp.py
@@ -98,8 +141,6 @@ SET(PathScripts_SRCS
PathScripts/PathPocketGui.py
PathScripts/PathPocketShape.py
PathScripts/PathPocketShapeGui.py
PathScripts/PathPost.py
PathScripts/PathPostProcessor.py
PathScripts/PathPreferences.py
PathScripts/PathPreferencesAdvanced.py
PathScripts/PathPreferencesPathDressup.py
@@ -153,10 +194,6 @@ SET(PathScripts_SRCS
PathScripts/PathVcarveGui.py
PathScripts/PathWaterline.py
PathScripts/PathWaterlineGui.py
PathScripts/PostUtils.py
PathScripts/PostUtilsArguments.py
PathScripts/PostUtilsExport.py
PathScripts/PostUtilsParse.py
PathScripts/__init__.py
)
@@ -168,39 +205,6 @@ SET(Generator_SRCS
Generators/toolchange_generator.py
)
SET(PathScripts_post_SRCS
PathScripts/post/__init__.py
PathScripts/post/centroid_post.py
PathScripts/post/comparams_post.py
PathScripts/post/dxf_post.py
PathScripts/post/dynapath_post.py
PathScripts/post/example_pre.py
PathScripts/post/fablin_post.py
PathScripts/post/fanuc_post.py
PathScripts/post/gcode_pre.py
PathScripts/post/grbl_post.py
PathScripts/post/heidenhain_post.py
PathScripts/post/jtech_post.py
PathScripts/post/KineticNCBeamicon2_post.py
PathScripts/post/linuxcnc_post.py
PathScripts/post/mach3_mach4_post.py
PathScripts/post/marlin_post.py
PathScripts/post/nccad_post.py
PathScripts/post/opensbp_post.py
PathScripts/post/opensbp_pre.py
PathScripts/post/philips_post.py
PathScripts/post/refactored_centroid_post.py
PathScripts/post/refactored_grbl_post.py
PathScripts/post/refactored_linuxcnc_post.py
PathScripts/post/refactored_mach3_mach4_post.py
PathScripts/post/refactored_test_post.py
PathScripts/post/rml_post.py
PathScripts/post/rrf_post.py
PathScripts/post/slic3r_pre.py
PathScripts/post/smoothie_post.py
PathScripts/post/uccnc_post.py
)
SET(PathPythonGui_SRCS
PathPythonGui/__init__.py
PathPythonGui/simple_edit_panel.py
@@ -328,8 +332,9 @@ SET(all_files
${PathPython_SRCS}
${PathPythonOp_SRCS}
${PathPythonOpGui_SRCS}
${PathPythonPost_SRCS}
${PathPythonPostScripts_SRCS}
${Generator_SRCS}
${PathScripts_post_SRCS}
${PathPythonGui_SRCS}
${Tools_SRCS}
${Tools_Bit_SRCS}
@@ -382,6 +387,20 @@ INSTALL(
Mod/Path/Path/Op/Gui
)
INSTALL(
FILES
${PathPythonPost_SRCS}
DESTINATION
Mod/Path/Path/Post
)
INSTALL(
FILES
${PathPythonPostScripts_SRCS}
DESTINATION
Mod/Path/Path/Post/scripts
)
INSTALL(
FILES
${Generator_SRCS}
@@ -404,13 +423,6 @@ INSTALL(
)
INSTALL(
FILES
${PathScripts_post_SRCS}
DESTINATION
Mod/Path/PathScripts/post
)
INSTALL(
FILES
${PathPythonGui_SRCS}

View File

@@ -82,7 +82,7 @@ private:
try {
std::string path = App::Application::getHomePath();
path += "Mod/Path/PathScripts/post/";
path += "Mod/Path/Path/Post/scripts/";
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());
@@ -113,7 +113,7 @@ private:
QFileInfo fileInfo = list.at(i);
if (fileInfo.baseName().toStdString() == processor) {
if (fileInfo.absoluteFilePath().contains(QString::fromLatin1("PathScripts"))) {
pre << "from PathScripts.post import " << processor;
pre << "from Path.Post.scripts import " << processor;
} else {
pre << "import " << processor;
}
@@ -149,7 +149,7 @@ private:
try {
std::string path = App::Application::getHomePath();
path += "Mod/Path/PathScripts/post/";
path += "Mod/Path/Path/Post/scripts/";
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());
@@ -189,7 +189,7 @@ private:
QFileInfo fileInfo = list.at(i);
if (fileInfo.baseName().toStdString() == processor) {
if (fileInfo.absoluteFilePath().contains(QString::fromLatin1("PathScripts"))) {
pre << "from PathScripts.post import " << processor;
pre << "from Path.Post.scripts import " << processor;
} else {
pre << "import " << processor;
}
@@ -225,7 +225,7 @@ private:
throw Py::RuntimeError("No object to export");
std::string path = App::Application::getHomePath();
path += "Mod/Path/PathScripts/post/";
path += "Mod/Path/Path/Post/scripts/";
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());
@@ -265,7 +265,7 @@ private:
QFileInfo fileInfo = list.at(i);
if (fileInfo.baseName().toStdString() == processor) {
if (fileInfo.absoluteFilePath().contains(QString::fromLatin1("PathScripts"))) {
pre << "from PathScripts.post import " << processor;
pre << "from Path.Post.scripts import " << processor;
} else {
pre << "import " << processor;
}

View File

@@ -34,7 +34,7 @@ import PathScripts.PathUtils as PathUtils
import os
import re
from PathScripts.PathPostProcessor import PostProcessor
from Path.Post.Processor import PostProcessor
from PySide import QtCore, QtGui
from datetime import datetime
from PySide.QtCore import QT_TRANSLATE_NOOP
@@ -530,7 +530,7 @@ class CommandPathPost:
def Activated(self):
Path.Log.track()
FreeCAD.ActiveDocument.openTransaction("Post Process the Selected path(s)")
FreeCADGui.addModule("PathScripts.PathPost")
FreeCADGui.addModule("Path.Post.Command")
# Attempt to figure out what the user wants to post-process
# If a job is selected, post that.

View File

@@ -31,10 +31,10 @@ import datetime
import os
import FreeCAD
import Path.Post.Utils as PostUtils
import Path.Post.UtilsParse as PostUtilsParse
from PathScripts import PathToolController
from PathScripts import PostUtils
from PathScripts import PostUtilsParse
# to distinguish python built-in open function from the one declared below

View File

@@ -33,8 +33,7 @@ import FreeCAD
from FreeCAD import Units
import Path
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
def create_comment(comment_string, comment_symbol):

View File

@@ -35,10 +35,10 @@ from __future__ import print_function
import FreeCAD
from FreeCAD import Units
import Path
import Path.Post.Utils as PostUtils
import argparse
import datetime
import shlex
from PathScripts import PostUtils
from PathScripts import PathUtils
TOOLTIP = """

View File

@@ -27,9 +27,9 @@ from __future__ import print_function
import os
import FreeCAD
from FreeCAD import Units
import Path.Post.Utils as PostUtils
import datetime
import PathScripts
import PathScripts.PostUtils as PostUtils
TOOLTIP = """
This is a postprocessor file for the Path workbench. It is used to

View File

@@ -22,7 +22,7 @@
import FreeCAD
import Path
import PathScripts.PostUtils as PostUtils
import Path.Post.Utils as PostUtils
TOOLTIP = """Example Post, using Path.Commands instead of Path.toGCode strings for Path gcode output."""

View File

@@ -30,7 +30,7 @@ doesn't do any manipulation of the path and doesn't write anything to disk. It
shows the dialog so you can see it. Useful for debugging, but not much else.
"""
import datetime
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
now = datetime.datetime.now()
SHOW_EDITOR = True

View File

@@ -33,10 +33,10 @@
from __future__ import print_function
import FreeCAD
from FreeCAD import Units
import Path.Post.Utils import PostUtils
import argparse
import datetime
import shlex
from PathScripts import PostUtils
TOOLTIP = """
This is a postprocessor file for the Path workbench. It is used to

View File

@@ -25,7 +25,7 @@
# ***************************************************************************
import datetime
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
now = datetime.datetime.now()

View File

@@ -29,7 +29,7 @@ import argparse
import datetime
import shlex
import os.path
from PathScripts import PostUtils
import Path.Post.Utils import PostUtils
TOOLTIP = """
This is a postprocessor file for the Path workbench. It is used to

View File

@@ -26,7 +26,7 @@
import FreeCAD
from FreeCAD import Units
import PathScripts.PostUtils as PostUtils
import Path.Post.Utils as PostUtils
import argparse
import datetime
import shlex

View File

@@ -21,9 +21,9 @@
# HEDENHAIN Post-Processor for FreeCAD
import argparse
import shlex
import Path.Post.Utils as PostUtils
import PathScripts
from PathScripts import PostUtils
import shlex
import math
# **************************************************************************#

View File

@@ -28,7 +28,7 @@ import Path
import argparse
import datetime
import shlex
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
TOOLTIP = """
This is a postprocessor file for the Path workbench. It is used to

View File

@@ -28,7 +28,7 @@ import Path
import argparse
import datetime
import shlex
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
TOOLTIP = """
This is a postprocessor file for the Path workbench. It is used to

View File

@@ -27,7 +27,7 @@ import Path
import argparse
import datetime
import shlex
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
TOOLTIP = """
This is a postprocessor file for the Path workbench. It is used to

View File

@@ -33,7 +33,7 @@ import shlex
import FreeCAD
from FreeCAD import Units
import PathScripts.PathUtil as PathUtil
import PathScripts.PostUtils as PostUtils
import Path.Post.Utils as PostUtils
Revised = "2020-11-03" # Revision date for this file.

View File

@@ -22,7 +22,7 @@
# ****************************************************************************/
"""Postprocessor to output real GCode for Max Computer GmbH nccad9."""
import FreeCAD
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
import datetime

View File

@@ -23,7 +23,7 @@
from __future__ import print_function
import datetime
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
TOOLTIP = """

View File

@@ -27,7 +27,7 @@
import FreeCAD
import argparse
import time
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
import math
TOOLTIP = """Post processor for Maho M 600E mill

View File

@@ -26,8 +26,8 @@
from __future__ import print_function
from PathScripts import PostUtilsArguments
from PathScripts import PostUtilsExport
import Path.Post.UtilsArguments as PostUtilsArguments
import Path.Post.UtilsExport as PostUtilsExport
#
# The following variables need to be global variables

View File

@@ -27,8 +27,8 @@
from __future__ import print_function
from PathScripts import PostUtilsArguments
from PathScripts import PostUtilsExport
import Path.Post.UtilsArguments as PostUtilsArguments
import Path.Post.UtilsExport as PostUtilsExport
#
# The following variables need to be global variables

View File

@@ -24,8 +24,8 @@
from __future__ import print_function
from PathScripts import PostUtilsArguments
from PathScripts import PostUtilsExport
import Path.Post.UtilsArguments as PostUtilsArguments
import Path.Post.UtilsExport as PostUtilsExport
#
# The following variables need to be global variables

View File

@@ -23,8 +23,8 @@
# ***************************************************************************/
from __future__ import print_function
from PathScripts import PostUtilsArguments
from PathScripts import PostUtilsExport
import Path.Post.UtilsArguments as PostUtilsArguments
import Path.Post.UtilsExport as PostUtilsExport
#
# The following variables need to be global variables

View File

@@ -24,8 +24,8 @@
from __future__ import print_function
from PathScripts import PostUtilsArguments
from PathScripts import PostUtilsExport
import Path.Post.UtilsArguments as PostUtilsArguments
import Path.Post.UtilsExport as PostUtilsExport
#
# The following variables need to be global variables

View File

@@ -36,7 +36,7 @@ http://paulbourke.net/dataformats/hpgl/
import FreeCAD
import Part
import PathScripts.PostUtils as PostUtils
import Path.Post.Utils as PostUtils
# to distinguish python built-in open function from the one declared below
if open.__module__ in ["__builtin__", "io"]:

View File

@@ -32,7 +32,7 @@ import shlex
import FreeCAD
from FreeCAD import Units
import PathScripts.PathUtil as PathUtil
import PathScripts.PostUtils as PostUtils
import Path.Post.Utils as PostUtils
Revised = "2021-10-21" # Revision date for this file.

View File

@@ -25,7 +25,7 @@ from __future__ import print_function
import argparse
import datetime
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
import FreeCAD
from FreeCAD import Units
import shlex

View File

@@ -37,7 +37,7 @@ import argparse
import datetime
# import shlex
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
VERSION = "0.0.4"

View File

@@ -28,7 +28,7 @@ import FreeCADGui
import Mesh
import Path
import PathScripts
import PathScripts.PathPost as PathPost
import Path.Post.Command as PathPost
import camotics
import io
import json

View File

@@ -60,7 +60,7 @@ def Startup():
from PathScripts import PathMillFaceGui
from PathScripts import PathPocketGui
from PathScripts import PathPocketShapeGui
from PathScripts import PathPost
from Path.Post import Command
from PathScripts import PathProbeGui
from PathScripts import PathProfileGui
from PathScripts import PathPropertyBagGui

View File

@@ -20,11 +20,11 @@
# * *
# ***************************************************************************
from PathScripts.PathPostProcessor import PostProcessor
from PySide import QtCore
from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD
import Path
import Path.Post.Processor as PostProcessor
import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathSetupSheet as PathSetupSheet
import PathScripts.PathStock as PathStock

View File

@@ -75,8 +75,8 @@ def preferences():
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
def pathScriptsSourcePath():
return os.path.join(FreeCAD.getHomePath(), "Mod/Path/PathScripts/")
def pathPostSourcePath():
return os.path.join(FreeCAD.getHomePath(), "Mod/Path/Path/Post/")
def pathDefaultToolsPath(sub=None):
@@ -160,8 +160,8 @@ def searchPathsPost():
if p:
paths.append(p)
paths.append(macroFilePath())
paths.append(os.path.join(pathScriptsSourcePath(), "post/"))
paths.append(pathScriptsSourcePath())
paths.append(os.path.join(pathPostSourcePath(), "scripts/"))
paths.append(pathPostSourcePath())
return paths

View File

@@ -22,13 +22,13 @@
import FreeCAD
import Path
import Path.Post.Processor as PostProcessor
import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathStock as PathStock
import json
from FreeCAD import Units
from PySide import QtCore, QtGui
from PathScripts.PathPostProcessor import PostProcessor
Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule())

View File

@@ -27,7 +27,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from PathScripts.post import centroid_post as postprocessor
from Path.Post.scripts import centroid_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())

View File

@@ -25,7 +25,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from importlib import reload
from PathScripts.post import grbl_post as postprocessor
from Path.Post.scripts import grbl_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())

View File

@@ -25,7 +25,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from importlib import reload
from PathScripts.post import linuxcnc_post as postprocessor
from Path.Post.scripts import linuxcnc_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
Path.Log.trackModule(Path.Log.thisModule())

View File

@@ -27,7 +27,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from PathScripts.post import mach3_mach4_post as postprocessor
from Path.Post.scripts import mach3_mach4_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())

View File

@@ -28,11 +28,11 @@ import unittest
import FreeCAD
import Path
from PathScripts import PathPost
import Path.Post.Command as PathPost
from PathScripts import PathPreferences
from PathScripts import PostUtils
import Path.Post.Utils as PostUtils
from PathScripts.PathPostProcessor import PostProcessor
import Path.Post.Processor as PostProcessor
# If KEEP_DEBUG_OUTPUT is False, remove the gcode file after the test succeeds.
# If KEEP_DEBUG_OUTPUT is True or the test fails leave the gcode file behind

View File

@@ -32,14 +32,14 @@ class TestPathPreferences(PathTestUtils.PathTestBase):
self.assertGreater(len(paths), 0)
def test01(self):
"""PathScripts is part of the posts search path."""
"""Path/Post is part of the posts search path."""
paths = PathPreferences.searchPathsPost()
self.assertEqual(len([p for p in paths if p.endswith("/PathScripts/")]), 1)
self.assertEqual(len([p for p in paths if p.endswith("/Path/Post/")]), 1)
def test02(self):
"""PathScripts/post is part of the posts search path."""
"""Path/Post/scripts is part of the posts search path."""
paths = PathPreferences.searchPathsPost()
self.assertEqual(len([p for p in paths if p.endswith("/PathScripts/post/")]), 1)
self.assertEqual(len([p for p in paths if p.endswith("/Path/Post/scripts/")]), 1)
def test03(self):
"""Available post processors include linuxcnc, grbl and opensbp."""

View File

@@ -27,7 +27,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from PathScripts.post import refactored_centroid_post as postprocessor
from Path.Post.scripts import refactored_centroid_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())

View File

@@ -27,7 +27,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from PathScripts.post import refactored_grbl_post as postprocessor
from Path.Post.scripts import refactored_grbl_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())

View File

@@ -27,7 +27,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from PathScripts.post import refactored_linuxcnc_post as postprocessor
from Path.Post.scripts import refactored_linuxcnc_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())

View File

@@ -27,7 +27,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from PathScripts.post import refactored_mach3_mach4_post as postprocessor
from Path.Post.scripts import refactored_mach3_mach4_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
Path.Log.trackModule(Path.Log.thisModule())

View File

@@ -27,7 +27,7 @@ import FreeCAD
import Path
import PathTests.PathTestUtils as PathTestUtils
from PathScripts.post import refactored_test_post as postprocessor
from Path.Post.scripts import refactored_test_post as postprocessor
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
@@ -136,7 +136,7 @@ class TestRefactoredTestPost(PathTestUtils.PathTestBase):
self.assertEqual(gcode.splitlines()[0], "(Exported by FreeCAD)")
self.assertEqual(
gcode.splitlines()[1],
"(Post Processor: PathScripts.post.refactored_test_post)",
"(Post Processor: Path.Post.scripts.refactored_test_post)",
)
self.assertEqual(gcode.splitlines()[2], "(Cam File: )")
self.assertIn("(Output Time: ", gcode.splitlines()[3])
@@ -168,7 +168,7 @@ G21
self.assertEqual(gcode.splitlines()[0], "(Exported by FreeCAD)")
self.assertEqual(
gcode.splitlines()[1],
"(Post Processor: PathScripts.post.refactored_test_post)",
"(Post Processor: Path.Post.scripts.refactored_test_post)",
)
self.assertEqual(gcode.splitlines()[2], "(Cam File: )")
self.assertIn("(Output Time: ", gcode.splitlines()[3])