From f349336fc8fe82f82f62eda0887910547a2e5c2d Mon Sep 17 00:00:00 2001 From: Lawrence Woestman Date: Mon, 24 Nov 2025 14:40:16 -0800 Subject: [PATCH] CAM: fix for linuxcnc ignoring --preamble argument, with test --- src/Mod/CAM/CAMTests/TestLinuxCNCPost.py | 11 +++++++++++ src/Mod/CAM/Path/Post/scripts/linuxcnc_post.py | 5 +---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Mod/CAM/CAMTests/TestLinuxCNCPost.py b/src/Mod/CAM/CAMTests/TestLinuxCNCPost.py index a33ee00998..68988f32d9 100644 --- a/src/Mod/CAM/CAMTests/TestLinuxCNCPost.py +++ b/src/Mod/CAM/CAMTests/TestLinuxCNCPost.py @@ -188,3 +188,14 @@ class TestLinuxCNCPost(PathTestUtils.PathTestBase): lines = gcode.splitlines() has_g64_without_p = any("G64" in line and "P" not in line for line in lines) self.assertTrue(has_g64_without_p, "Expected G64 without P parameter when tolerance is 0") + + def test_blend_interaction_with_preamble_argument(self): + """Test interaction with a --preamble command line argument.""" + self.profile_op.Path = Path.Path([]) + self.job.PostProcessorArgs = ( + '--no-header --no-comments --blend-mode BLEND --preamble="G80 G90" --no-show-editor' + ) + gcode = self.post.export()[0][1] + lines = gcode.splitlines() + self.assertEqual(lines[0], "G80 G90") + self.assertEqual(lines[1], "G64") diff --git a/src/Mod/CAM/Path/Post/scripts/linuxcnc_post.py b/src/Mod/CAM/Path/Post/scripts/linuxcnc_post.py index 71e22a9d3e..fabf340ff5 100644 --- a/src/Mod/CAM/Path/Post/scripts/linuxcnc_post.py +++ b/src/Mod/CAM/Path/Post/scripts/linuxcnc_post.py @@ -172,10 +172,7 @@ M2""" # Update PREAMBLE with blend command blend_cmd = self._get_blend_command() - self.values[ - "PREAMBLE" - ] = f"""G17 G54 G40 G49 G80 G90 -{blend_cmd}""" + self.values["PREAMBLE"] += f'\n{blend_cmd}' return flag, args