CAM: Post Processor Dyna_4060_Post - various bug fixes and updates (#27202)

* various bug fixes and updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Dan Henderson
2026-02-02 11:07:31 -06:00
committed by GitHub
parent 1c90c1ec44
commit 21a597a85e

View File

@@ -50,22 +50,6 @@ 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")
@@ -78,17 +62,11 @@ 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="'
+ PREAMBLE.replace("\n", "\\n")
+ '"',
default=PREAMBLE,
help='set commands to be issued before the first command, default="G17\\nG90\\nG80\\nG40\\n"',
)
parser.add_argument(
"--postamble",
help='set commands to be issued after the last command, default="'
+ POSTAMBLE.replace("\n", "\\n")
+ '"',
default=POSTAMBLE,
help='set commands to be issued after the last command, default="M09\\nM05\\nG80\\nG40\\nG17\\nG90\\nM30\\n"',
)
parser.add_argument(
"--inches", action="store_true", help="Convert output for US imperial mode (G70)"
@@ -131,7 +109,7 @@ SPINDLE_SPEED = 0
UNITS = "G71" # G71 for metric, G70 for US standard
UNIT_SPEED_FORMAT = "mm/min"
UNIT_FORMAT = "mm"
MACHINE_NAME = "Delta 4060"
MACHINE_NAME = "Delta_4060"
CORNER_MIN = {"x": 0, "y": 0, "z": 0}
CORNER_MAX = {"x": 660, "y": 355, "z": 152}
PRECISION = 3
@@ -151,6 +129,21 @@ 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
@@ -299,7 +292,7 @@ def export(objectslist, filename, argstring):
if FreeCAD.GuiUp and SHOW_EDITOR:
dia = PostUtils.GCodeEditorDialog()
dia.editor.setPlainText(gcode)
dia.editor.setText(gcode)
result = dia.exec_()
if result:
final = dia.editor.toPlainText()
@@ -405,7 +398,33 @@ def parse(pathobj):
if c.Name.startswith("(") and not OUTPUT_COMMENTS: # command is a comment
continue
# Handle G84/G74 tapping cycles
if command in ("G84", "G74") and "F" in c.Parameters:
pitch_mm = float(c.Parameters["F"])
c.Parameters.pop("F") # Remove F from output, we'll handle it
# Get spindle speed (from S param or last known value)
spindle_speed = None
if "S" in c.Parameters:
spindle_speed = float(c.Parameters["S"])
c.Parameters.pop("S")
# Convert pitch to inches if needed
if UNITS == "G70": # imperial
pitch = pitch_mm / 25.4
else:
pitch = pitch_mm
# Calculate feed rate
if spindle_speed is not None:
feed_rate = pitch * spindle_speed
speed = Units.Quantity(feed_rate, UNIT_SPEED_FORMAT)
outstring.append(
"F" + format(float(speed.getValueAs(UNIT_SPEED_FORMAT)), precision_string)
)
else:
# No spindle speed found, output pitch as F
outstring.append("F" + format(pitch, precision_string))
# Now add the remaining parameters in order
for param in params:
if param in c.Parameters:
@@ -425,7 +444,7 @@ def parse(pathobj):
# This fixes an error thrown by Dynapath due to missing and
# required XYZ move after Tool change.
elif param == "Z" and (
c.Parameters["Z"] == clearanceHeight and c.Parameters["Z"] != lastZ
c.Parameters["Z"] == clearanceHeight and command in ["G0", "G00"]
):
x = 0
y = 0
@@ -505,7 +524,7 @@ def parse(pathobj):
) # First Reference plan (Safe Height)
elif param == "P":
outstring.append(
"L" + format(c.Parameters[param], precision_string)
"L" + format(c.Parameters[param], ".1f")
) # Converts "P" to "L" for dynapath.
else:
if (