From e155e0a97632106ffa9f80faa034b0a17098cc98 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Fri, 28 Nov 2025 14:48:51 +0100 Subject: [PATCH] CAM: Ensure pre-/postamble help text matches active values by avoiding duplication Make sure to use the active default values for preamble and postamble in the help text, and provide the current default values as the default in the add_argument(). The only exception is uccnc_post.py, where the real default value depend on the use of --no-comments, and sending the default argument to add_argument() would change behaviour. This change was inspired by the changes done to fix (#20792) in d84d9c9bd19eff174a6a5de29282be5808ff1be4. --- .../Post/scripts/KineticNCBeamicon2_post.py | 32 +++++++------ .../Path/Post/scripts/dynapath_4060_post.py | 41 ++++++++++------- .../CAM/Path/Post/scripts/dynapath_post.py | 46 +++++++++++-------- src/Mod/CAM/Path/Post/scripts/estlcam_post.py | 8 +++- .../CAM/Path/Post/scripts/fangling_post.py | 33 +++++++------ src/Mod/CAM/Path/Post/scripts/fanuc_post.py | 31 ++++++++----- .../CAM/Path/Post/scripts/grbl_legacy_post.py | 8 +++- src/Mod/CAM/Path/Post/scripts/jtech_post.py | 28 ++++++----- .../Path/Post/scripts/linuxcnc_legacy_post.py | 28 ++++++----- .../Post/scripts/mach3_mach4_legacy_post.py | 28 ++++++----- src/Mod/CAM/Path/Post/scripts/marlin_post.py | 24 ++++++---- src/Mod/CAM/Path/Post/scripts/rrf_post.py | 25 ++++++---- src/Mod/CAM/Path/Post/scripts/uccnc_post.py | 8 +++- src/Mod/CAM/Path/Post/scripts/wedm_post.py | 30 ++++++------ 14 files changed, 221 insertions(+), 149 deletions(-) diff --git a/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py b/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py index 9d5c6548e1..dc70b8e2bd 100644 --- a/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py +++ b/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py @@ -57,6 +57,18 @@ import KineticNCBeamicon2_post KineticNCBeamicon2_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """% +G17 G21 G40 G49 G80 G90 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 +M09 +G17 G90 G80 G40 +M30 +""" + now = datetime.datetime.now() parser = argparse.ArgumentParser( @@ -74,11 +86,15 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help=r'set commands to be issued before the first command, default="%%\nG17 G21 G40 G49 G80 G90\nM08\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help=r'set commands to be issued after the last command, default="M05 M09\nG17 G90 G80 G40\nM30\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -112,18 +128,6 @@ CORNER_MIN = {"x": 0, "y": 0, "z": 0} CORNER_MAX = {"x": 1000, "y": 600, "z": 300} PRECISION = 3 -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """% -G17 G21 G40 G49 G80 G90 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M05 -M09 -G17 G90 G80 G40 -M30 -""" - # Pre operation text will be inserted before every operation PRE_OPERATION = """""" diff --git a/src/Mod/CAM/Path/Post/scripts/dynapath_4060_post.py b/src/Mod/CAM/Path/Post/scripts/dynapath_4060_post.py index 9770c3c8df..9e932dac64 100644 --- a/src/Mod/CAM/Path/Post/scripts/dynapath_4060_post.py +++ b/src/Mod/CAM/Path/Post/scripts/dynapath_4060_post.py @@ -50,6 +50,22 @@ import delta_4060_post delta_4060_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """G17 +G90 +G80 +G40 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 +G80 +G40 +G17 +G90 +M30 +""" + parser = argparse.ArgumentParser(prog="delta_4060", add_help=False) parser.add_argument("--no-header", action="store_true", help="suppress header output") parser.add_argument("--no-comments", action="store_true", help="suppress comment output") @@ -62,11 +78,17 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17\\nG90\\nG80\\nG40\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', + default=PREAMBLE, ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M09\\nM05\\nG80\\nG40\\nG17\\nG90\\nM30\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', + default=POSTAMBLE, ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G70)" @@ -129,21 +151,6 @@ GCODE_MAP = { "G59": "E06", } -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """G17 -G90 -G80 -G40 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M05 -G80 -G40 -G17 -G90 -M30 -""" # Create following variable for use with the 2nd reference plane. clearanceHeight = None diff --git a/src/Mod/CAM/Path/Post/scripts/dynapath_post.py b/src/Mod/CAM/Path/Post/scripts/dynapath_post.py index 129d80f08a..c68b0d03c3 100644 --- a/src/Mod/CAM/Path/Post/scripts/dynapath_post.py +++ b/src/Mod/CAM/Path/Post/scripts/dynapath_post.py @@ -76,6 +76,24 @@ import dynapath_post dynapath_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """G17 +G90 +;G90.1 ;needed for simulation only +G80 +G40 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M09 +M05 +G80 +G40 +G17 +G90 +M30 +""" + parser = argparse.ArgumentParser(prog="dynapath_post", add_help=False) parser.add_argument("--no-header", action="store_true", help="suppress header output") parser.add_argument("--no-comments", action="store_true", help="suppress comment output") @@ -88,11 +106,17 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17\\nG90\\nG80\\nG40\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', + default=PREAMBLE, ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M09\\nM05\\nG80\\nG40\\nG17\\nG90\\nM30\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', + default=POSTAMBLE, ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -121,24 +145,6 @@ MACHINE_NAME = "Tree MM" CORNER_MIN = {"x": -340, "y": 0, "z": 0} CORNER_MAX = {"x": 340, "y": -355, "z": -150} -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """G17 -G90 -;G90.1 ;needed for simulation only -G80 -G40 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M09 -M05 -G80 -G40 -G17 -G90 -M30 -""" - # Pre operation text will be inserted before every operation PRE_OPERATION = """""" diff --git a/src/Mod/CAM/Path/Post/scripts/estlcam_post.py b/src/Mod/CAM/Path/Post/scripts/estlcam_post.py index 9383c8bdca..1a4fdea541 100644 --- a/src/Mod/CAM/Path/Post/scripts/estlcam_post.py +++ b/src/Mod/CAM/Path/Post/scripts/estlcam_post.py @@ -115,11 +115,15 @@ parser.add_argument( ) parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default=""', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M5\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument("--inches", action="store_true", help="convert output for US imperial mode") diff --git a/src/Mod/CAM/Path/Post/scripts/fangling_post.py b/src/Mod/CAM/Path/Post/scripts/fangling_post.py index 938968ebc9..2d5089b4b1 100644 --- a/src/Mod/CAM/Path/Post/scripts/fangling_post.py +++ b/src/Mod/CAM/Path/Post/scripts/fangling_post.py @@ -57,6 +57,18 @@ import FangLing_post FangLing_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +# PREAMBLE = '''G17 G54 G40 G49 G80 G90''' +# Changed to match preamble produced by Fusion 360 +PREAMBLE = """G90 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M8 +G90 G40 +M2 +""" + now = datetime.datetime.now() parser = argparse.ArgumentParser(prog="FangLing", add_help=False) @@ -68,11 +80,16 @@ parser.add_argument( ) parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( - "--preamble", help='set commands to be issued before the first command, default="G90\\n"' + "--preamble", + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M8\\nG90 G40\\nM2\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -108,18 +125,6 @@ CORNER_MIN = {"x": 0, "y": 0, "z": 0} CORNER_MAX = {"x": 500, "y": 300, "z": 300} PRECISION = 3 -# Preamble text will appear at the beginning of the GCODE output file. -# PREAMBLE = '''G17 G54 G40 G49 G80 G90''' -# Changed to match preamble produced by Fusion 360 -PREAMBLE = """G90 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M8 -G90 G40 -M2 -""" - # Pre operation text will be inserted before every operation PRE_OPERATION = """""" diff --git a/src/Mod/CAM/Path/Post/scripts/fanuc_post.py b/src/Mod/CAM/Path/Post/scripts/fanuc_post.py index 85a3d88d50..1a3a60f167 100644 --- a/src/Mod/CAM/Path/Post/scripts/fanuc_post.py +++ b/src/Mod/CAM/Path/Post/scripts/fanuc_post.py @@ -49,6 +49,16 @@ import fanuc_post fanuc_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +DEFAULT_PREAMBLE = """G17 G54 G40 G49 G80 G90 +""" + +# Postamble text will appear following the last operation. +DEFAULT_POSTAMBLE = """M05 +G17 G54 G90 G80 G40 +M30 +""" + now = datetime.datetime.now() parser = argparse.ArgumentParser(prog="fanuc", add_help=False) @@ -63,11 +73,15 @@ parser.add_argument( parser.add_argument("--precision", help="number of digits of precision, default=3 (mm) or 4 (in)") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17 G54 G40 G49 G80 G90\\n"', + help='set commands to be issued before the first command, default="' + + DEFAULT_PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M05\\nG17 G54 G90 G80 G40\\nM30\\n"', + help='set commands to be issued after the last command, default="' + + DEFAULT_POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -122,15 +136,8 @@ PRECISION = 3 # rigid tapping. tapSpeed = 0 -# Preamble text will appear at the beginning of the GCODE output file. -DEFAULT_PREAMBLE = """G17 G54 G40 G49 G80 G90 -""" - -# Postamble text will appear following the last operation. -DEFAULT_POSTAMBLE = """M05 -G17 G54 G90 G80 G40 -M30 -""" +PREAMBLE = DEFAULT_PREAMBLE +POSTAMBLE = DEFAULT_POSTAMBLE # Pre operation text will be inserted before every operation PRE_OPERATION = """""" @@ -150,6 +157,8 @@ def processArguments(argstring): global OUTPUT_LINE_NUMBERS global SHOW_EDITOR global PRECISION + global DEFAULT_PREAMBLE + global DEFAULT_POSTAMBLE global PREAMBLE global POSTAMBLE global UNITS diff --git a/src/Mod/CAM/Path/Post/scripts/grbl_legacy_post.py b/src/Mod/CAM/Path/Post/scripts/grbl_legacy_post.py index 694e078f92..2091b3e5dd 100644 --- a/src/Mod/CAM/Path/Post/scripts/grbl_legacy_post.py +++ b/src/Mod/CAM/Path/Post/scripts/grbl_legacy_post.py @@ -122,11 +122,15 @@ parser.add_argument( ) parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17 G90\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M5\\nG17 G90\\nM2\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" diff --git a/src/Mod/CAM/Path/Post/scripts/jtech_post.py b/src/Mod/CAM/Path/Post/scripts/jtech_post.py index f84309b223..5a5761d9a5 100644 --- a/src/Mod/CAM/Path/Post/scripts/jtech_post.py +++ b/src/Mod/CAM/Path/Post/scripts/jtech_post.py @@ -44,6 +44,16 @@ import jtech_post jtech_post.export(object,"/path/to/file.ngc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """M05 S0 +G90 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 S0 +M2 +""" + now = datetime.datetime.now() parser = argparse.ArgumentParser(prog="jtech", add_help=False) @@ -58,11 +68,15 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="M05 S0\\nG90\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M05 S0\\nM2\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -100,16 +114,6 @@ UNIT_FORMAT = "mm" MACHINE_NAME = "JTECH Photonic Laser" PRECISION = 3 -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """M05 S0 -G90 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M05 S0 -M2 -""" - PRE_FEED = """M03 G4 P{} """ diff --git a/src/Mod/CAM/Path/Post/scripts/linuxcnc_legacy_post.py b/src/Mod/CAM/Path/Post/scripts/linuxcnc_legacy_post.py index d5655f3b3a..0251bfcf96 100644 --- a/src/Mod/CAM/Path/Post/scripts/linuxcnc_legacy_post.py +++ b/src/Mod/CAM/Path/Post/scripts/linuxcnc_legacy_post.py @@ -45,6 +45,16 @@ import linuxcnc_legacy_post linuxcnc_legacy_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """G17 G54 G40 G49 G80 G90 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 +G17 G54 G90 G80 G40 +M2 +""" + now = datetime.datetime.now() parser = argparse.ArgumentParser(prog="linuxcnc", add_help=False) @@ -59,11 +69,15 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17 G54 G40 G49 G80 G90\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M05\\nG17 G54 G90 G80 G40\\nM2\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -106,16 +120,6 @@ PRECISION = 3 RIGID_TAP = False -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """G17 G54 G40 G49 G80 G90 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M05 -G17 G54 G90 G80 G40 -M2 -""" - # Pre operation text will be inserted before every operation PRE_OPERATION = """""" diff --git a/src/Mod/CAM/Path/Post/scripts/mach3_mach4_legacy_post.py b/src/Mod/CAM/Path/Post/scripts/mach3_mach4_legacy_post.py index a2f7952b87..650a105a28 100644 --- a/src/Mod/CAM/Path/Post/scripts/mach3_mach4_legacy_post.py +++ b/src/Mod/CAM/Path/Post/scripts/mach3_mach4_legacy_post.py @@ -43,6 +43,16 @@ import mach3_4_legacy_post mach3_4_legacy_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """G17 G54 G40 G49 G80 G90 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 +G17 G54 G90 G80 G40 +M2 +""" + now = datetime.datetime.now() parser = argparse.ArgumentParser(prog="mach3_4", add_help=False) @@ -57,11 +67,15 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17 G54 G40 G49 G80 G90\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M05\\nG17 G54 G90 G80 G40\\nM2\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -101,16 +115,6 @@ CORNER_MIN = {"x": 0, "y": 0, "z": 0} CORNER_MAX = {"x": 500, "y": 300, "z": 300} PRECISION = 3 -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """G17 G54 G40 G49 G80 G90 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M05 -G17 G54 G90 G80 G40 -M2 -""" - # Pre operation text will be inserted before every operation PRE_OPERATION = """""" diff --git a/src/Mod/CAM/Path/Post/scripts/marlin_post.py b/src/Mod/CAM/Path/Post/scripts/marlin_post.py index cc7e29fb65..66d4326c95 100644 --- a/src/Mod/CAM/Path/Post/scripts/marlin_post.py +++ b/src/Mod/CAM/Path/Post/scripts/marlin_post.py @@ -88,6 +88,13 @@ POST_OPERATION = """""" # Post operation text will be inserted after TOOL_CHANGE = """""" # Tool Change commands will be inserted # before a tool change +# Default preamble text will appear at the beginning of the gcode output file. +PREAMBLE = """""" + +# Default postamble text will appear following the last operation. +POSTAMBLE = """M5 +""" + # ***************************************************************************** # * Initial gcode output options, changeable via command line arguments * # ***************************************************************************** @@ -155,10 +162,16 @@ parser.add_argument( help="do not translate drill cycles G81, G82, G83 into G0/G1 movements", ) parser.add_argument( - "--preamble", help='set commands to be issued before the first command, default=""' + "--preamble", + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( - "--postamble", help='set commands to be issued after the last command, default="M5\\n"' + "--postamble", + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument("--tool-change", action="store_true", help="Insert M6 for all tool changes") parser.add_argument( @@ -193,13 +206,6 @@ TOOLTIP_ARGS = parser.format_help() # * one command per line. * # ***************************************************************************** -# Default preamble text will appear at the beginning of the gcode output file. -PREAMBLE = """""" - -# Default postamble text will appear following the last operation. -POSTAMBLE = """M5 -""" - # ***************************************************************************** # * Internal global variables * # ***************************************************************************** diff --git a/src/Mod/CAM/Path/Post/scripts/rrf_post.py b/src/Mod/CAM/Path/Post/scripts/rrf_post.py index 74e5d8d725..9bc21cb7cb 100644 --- a/src/Mod/CAM/Path/Post/scripts/rrf_post.py +++ b/src/Mod/CAM/Path/Post/scripts/rrf_post.py @@ -99,6 +99,14 @@ OUTPUT_BCNC = False # Add bCNC operation block headers in output # gcode file SHOW_EDITOR = True # Display the resulting gcode file OUTPUT_TOOL_CHANGE = True + +# Default preamble text will appear at the beginning of the gcode output file. +PREAMBLE = """""" + +# Default postamble text will appear following the last operation. +POSTAMBLE = """M5 +""" + # ***************************************************************************** # * Command line arguments * # ***************************************************************************** @@ -153,10 +161,16 @@ parser.add_argument( help="do not translate drill cycles G81, G82, G83 into G0/G1 movements", ) parser.add_argument( - "--preamble", help='set commands to be issued before the first command, default=""' + "--preamble", + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( - "--postamble", help='set commands to be issued after the last command, default="M5\\n"' + "--postamble", + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument("--tool-change", action="store_true", help="Insert M6 for all tool changes") parser.add_argument( @@ -191,13 +205,6 @@ TOOLTIP_ARGS = parser.format_help() # * one command per line. * # ***************************************************************************** -# Default preamble text will appear at the beginning of the gcode output file. -PREAMBLE = """""" - -# Default postamble text will appear following the last operation. -POSTAMBLE = """M5 -""" - # ***************************************************************************** # * Internal global variables * # ***************************************************************************** diff --git a/src/Mod/CAM/Path/Post/scripts/uccnc_post.py b/src/Mod/CAM/Path/Post/scripts/uccnc_post.py index 0743ddfd01..a14c4cd743 100644 --- a/src/Mod/CAM/Path/Post/scripts/uccnc_post.py +++ b/src/Mod/CAM/Path/Post/scripts/uccnc_post.py @@ -257,11 +257,15 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17\\nG54\\G40\\nG49\\nG90\\nG80\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE_DEFAULT_NO_COMMENT.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M05\\nG17\\nG54\\nG0\\nG90\\nG80\\nM30\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE_DEFAULT_NO_COMMENT.replace("\n", "\\n") + + '"', ) parser.add_argument("--inches", action="store_true", help="lengths in [in], G20") parser.add_argument("--metric", action="store_true", help="lengths in [mm], G21") diff --git a/src/Mod/CAM/Path/Post/scripts/wedm_post.py b/src/Mod/CAM/Path/Post/scripts/wedm_post.py index 0d56451bf7..8476fabecf 100644 --- a/src/Mod/CAM/Path/Post/scripts/wedm_post.py +++ b/src/Mod/CAM/Path/Post/scripts/wedm_post.py @@ -48,6 +48,17 @@ import wedm_post wedm_post.export(object,"/path/to/file.ncc","") """ +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """G17 G54 G40 G49 G80 G90 +""" + + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 +G17 G54 G90 G80 G40 +M2 +""" + now = datetime.datetime.now() parser = argparse.ArgumentParser(prog="wedm", add_help=False) @@ -71,11 +82,15 @@ parser.add_argument("--precision", default="3", help="number of digits of precis parser.add_argument("--fixed-length", default="0", help="use fixed length coordinates, default=0") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="G17 G54 G40 G49 G80 G90\\n"', + help='set commands to be issued before the first command, default="' + + PREAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M05\\nG17 G54 G90 G80 G40\\nM2\\n"', + help='set commands to be issued after the last command, default="' + + POSTAMBLE.replace("\n", "\\n") + + '"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" @@ -144,17 +159,6 @@ CORNER_MIN = {"x": 0, "y": 0, "z": 0} CORNER_MAX = {"x": 500, "y": 300, "z": 300} PRECISION = 3 -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """G17 G54 G40 G49 G80 G90 -""" - - -# Postamble text will appear following the last operation. -POSTAMBLE = """M05 -G17 G54 G90 G80 G40 -M2 -""" - # Pre operation text will be inserted before every operation PRE_OPERATION = """"""