From 730d0a567dfc115be4a55af12006d2578200d589 Mon Sep 17 00:00:00 2001 From: Lawrence Woestman Date: Wed, 26 Mar 2025 14:50:36 -0700 Subject: [PATCH 1/2] CAM: Enabled coolant in the refactored_grbl post, with test --- .../CAM/CAMTests/TestRefactoredGrblPost.py | 19 +++++++++++++++++++ .../Path/Post/scripts/refactored_grbl_post.py | 1 + 2 files changed, 20 insertions(+) diff --git a/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py b/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py index a942985053..eed8364a92 100644 --- a/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py +++ b/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py @@ -332,3 +332,22 @@ M2 result = gcode.splitlines()[15] expected = "(comment)" self.assertEqual(result, expected) + + def test100(self): + """ + Test if coolant is enabled. + """ + nl = "\n" + + c = Path.Command("M7") + c1 = Path.Command("M8") + c2 = Path.Command("M9") + + self.profile_op.Path = Path.Path([c, c1, c2]) + + self.job.PostProcessorArgs = "--no-header --no-show-editor" + gcode = self.post.export()[0][1] + # print(f"--------{nl}{gcode}--------{nl}") + self.assertEqual(gcode.splitlines()[15], "M7") + self.assertEqual(gcode.splitlines()[16], "M8") + self.assertEqual(gcode.splitlines()[17], "M9") diff --git a/src/Mod/CAM/Path/Post/scripts/refactored_grbl_post.py b/src/Mod/CAM/Path/Post/scripts/refactored_grbl_post.py index 811448ad06..ea47280a8b 100644 --- a/src/Mod/CAM/Path/Post/scripts/refactored_grbl_post.py +++ b/src/Mod/CAM/Path/Post/scripts/refactored_grbl_post.py @@ -75,6 +75,7 @@ class Refactored_Grbl(PostProcessor): # Set any values here that need to override the default values set # in the parent routine. # + values["ENABLE_COOLANT"] = True # # If this is set to True, then commands that are placed in # comments that look like (MC_RUN_COMMAND: blah) will be output. From 8cb1f6fc1c0ea8d66f089ceb2e65ba46a5524971 Mon Sep 17 00:00:00 2001 From: Lawrence Woestman Date: Tue, 22 Apr 2025 14:57:45 -0700 Subject: [PATCH 2/2] CAM: Fix tool change output errors, with tests --- .../CAM/CAMTests/TestRefactoredGrblPost.py | 1 - .../CAM/CAMTests/TestRefactoredTestPost.py | 60 ++++++++++--------- .../CAMTests/TestRefactoredTestPostGCodes.py | 56 +---------------- .../CAMTests/TestRefactoredTestPostMCodes.py | 26 ++++++-- src/Mod/CAM/Path/Post/UtilsParse.py | 5 +- 5 files changed, 59 insertions(+), 89 deletions(-) diff --git a/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py b/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py index eed8364a92..cdad7582ff 100644 --- a/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py +++ b/src/Mod/CAM/CAMTests/TestRefactoredGrblPost.py @@ -143,7 +143,6 @@ M2 expected = """G17 G90 G21 G54 -M6 T1 M5 G17 G90 M2 diff --git a/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py b/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py index 1dadfddce0..58b05f44a6 100644 --- a/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py +++ b/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py @@ -103,8 +103,8 @@ class TestRefactoredTestPost(PathTestUtils.PathTestBase): gcode = self.post.export()[0][1] if debug: print(f"--------{nl}{gcode}--------{nl}") - # there are 4 lines of "other stuff" before the line we are interested in - self.assertEqual(gcode.splitlines()[4], expected) + # there are 3 lines of "other stuff" before the line we are interested in + self.assertEqual(gcode.splitlines()[3], expected) def multi_compare(self, path, expected, args, debug=False): """Perform a test with multiple lines of gcode comparison.""" @@ -144,12 +144,12 @@ class TestRefactoredTestPost(PathTestUtils.PathTestBase): self.job.PostProcessorArgs = "--axis-modal" gcode = self.post.export()[0][1] # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(gcode.splitlines()[5], "G0 Y30.000") + self.assertEqual(gcode.splitlines()[4], "G0 Y30.000") self.job.PostProcessorArgs = "--no-axis-modal" gcode = self.post.export()[0][1] # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(gcode.splitlines()[5], "G0 X10.000 Y30.000 Z30.000") + self.assertEqual(gcode.splitlines()[4], "G0 X10.000 Y30.000 Z30.000") ############################################################################# @@ -172,7 +172,6 @@ G54 (Block-name: TC: Default Tool) (Block-expand: 0) (Block-enable: 1) -M6 T1 (Block-name: Profile) (Block-expand: 0) (Block-enable: 1) @@ -187,7 +186,6 @@ M6 T1 """G90 G21 G54 -M6 T1 """, "--no-bcnc", ) @@ -211,7 +209,6 @@ M6 T1 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -238,7 +235,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -274,7 +270,6 @@ G90 """G90 G20 G54 -M6 T1 G0 X1.0000 Y2.0000 G0 Z8.0000 G90 @@ -439,14 +434,14 @@ G54 # print(f"--------{nl}{gcode}--------{nl}") # Note: The "internal" F speed is in mm/s, # while the output F speed is in mm/min. - self.assertEqual(gcode.splitlines()[4], "G1 X10.000 Y20.000 Z30.000 F7387.407") + self.assertEqual(gcode.splitlines()[3], "G1 X10.000 Y20.000 Z30.000 F7387.407") self.job.PostProcessorArgs = "--feed-precision=2" gcode = self.post.export()[0][1] # print(f"--------{nl}{gcode}--------{nl}") # Note: The "internal" F speed is in mm/s, # while the output F speed is in mm/min. - self.assertEqual(gcode.splitlines()[4], "G1 X10.000 Y20.000 Z30.000 F7387.41") + self.assertEqual(gcode.splitlines()[3], "G1 X10.000 Y20.000 Z30.000 F7387.41") ############################################################################# @@ -522,13 +517,11 @@ G54 self.assertEqual(split_gcode[4], "G90") self.assertEqual(split_gcode[5], "G21") self.assertEqual(split_gcode[6], "G54") - self.assertEqual(split_gcode[7], "M6 T1") # Test without comments or header. expected = """G90 G21 G54 -M6 T1 """ self.job.PostProcessorArgs = "--no-comments --no-header" gcode = self.post.export()[0][1] @@ -539,7 +532,7 @@ M6 T1 def test00160(self): """Test Line Numbers.""" - self.single_compare("G0 X10 Y20 Z30", "N140 G0 X10.000 Y20.000 Z30.000", "--line-numbers") + self.single_compare("G0 X10 Y20 Z30", "N130 G0 X10.000 Y20.000 Z30.000", "--line-numbers") ############################################################################# @@ -555,7 +548,7 @@ M6 T1 # print(f"--------{nl}{gcode}--------{nl}") self.assertEqual(gcode.splitlines()[1], "G20") self.assertEqual( - gcode.splitlines()[4], + gcode.splitlines()[3], "G0 X0.3937 Y0.7874 Z1.1811 A10.0000 B20.0000 C30.0000 U0.3937 V0.7874 W1.1811", ) @@ -575,11 +568,11 @@ M6 T1 self.job.PostProcessorArgs = "--modal" gcode = self.post.export()[0][1] # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(gcode.splitlines()[5], "X10.000 Y30.000 Z30.000") + self.assertEqual(gcode.splitlines()[4], "X10.000 Y30.000 Z30.000") self.job.PostProcessorArgs = "--no-modal" gcode = self.post.export()[0][1] # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(gcode.splitlines()[5], "G0 X10.000 Y30.000 Z30.000") + self.assertEqual(gcode.splitlines()[4], "G0 X10.000 Y30.000 Z30.000") ############################################################################# @@ -743,7 +736,7 @@ M6 T1 self.profile_op.Path = Path.Path([c, c2]) - self.job.PostProcessorArgs = "--tlo" + self.job.PostProcessorArgs = "--tlo --tool_change" gcode = self.post.export()[0][1] split_gcode = gcode.splitlines() # print(f"--------{nl}{gcode}--------{nl}") @@ -752,7 +745,7 @@ M6 T1 self.assertEqual(split_gcode[7], "M3 S3000") # suppress TLO - self.job.PostProcessorArgs = "--no-tlo" + self.job.PostProcessorArgs = "--no-tlo --tool_change" gcode = self.post.export()[0][1] split_gcode = gcode.splitlines() # print(f"--------{nl}{gcode}--------{nl}") @@ -769,19 +762,30 @@ M6 T1 c2 = Path.Command("M3 S3000") self.profile_op.Path = Path.Path([c, c2]) - self.job.PostProcessorArgs = "--tool_change" + self.job.PostProcessorArgs = "--no-comments --no-tool_change" + gcode = self.post.export()[0][1] + split_gcode = gcode.splitlines() + # print(f"--------{nl}{gcode}--------{nl}") + self.assertEqual(split_gcode[2], "G54") + self.assertEqual(split_gcode[3], "M3 S3000") + + self.job.PostProcessorArgs = "--no-comments --tool_change" gcode = self.post.export()[0][1] split_gcode = gcode.splitlines() # print(f"--------{nl}{gcode}--------{nl}") self.assertEqual(split_gcode[4], "M6 T2") - self.assertEqual(split_gcode[5], "M3 S3000") self.job.PostProcessorArgs = "--comments --no-tool_change" gcode = self.post.export()[0][1] split_gcode = gcode.splitlines() # print(f"--------{nl}{gcode}--------{nl}") self.assertEqual(split_gcode[13], "(M6 T2)") - self.assertEqual(split_gcode[14], "M3 S3000") + + self.job.PostProcessorArgs = "--comments --tool_change" + gcode = self.post.export()[0][1] + split_gcode = gcode.splitlines() + # print(f"--------{nl}{gcode}--------{nl}") + self.assertEqual(split_gcode[13], "M6 T2") ############################################################################# @@ -795,14 +799,14 @@ M6 T1 self.job.PostProcessorArgs = "" gcode = self.post.export()[0][1] # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(gcode.splitlines()[4], "M3 S3000") + self.assertEqual(gcode.splitlines()[3], "M3 S3000") self.job.PostProcessorArgs = "--wait-for-spindle=1.23456" gcode = self.post.export()[0][1] split_gcode = gcode.splitlines() # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(split_gcode[4], "M3 S3000") - self.assertEqual(split_gcode[5], "G4 P1.23456") + self.assertEqual(split_gcode[3], "M3 S3000") + self.assertEqual(split_gcode[4], "G4 P1.23456") c = Path.Command("M4 S3000") self.profile_op.Path = Path.Path([c]) @@ -812,11 +816,11 @@ M6 T1 self.job.PostProcessorArgs = "" gcode = self.post.export()[0][1] # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(gcode.splitlines()[4], "M4 S3000") + self.assertEqual(gcode.splitlines()[3], "M4 S3000") self.job.PostProcessorArgs = "--wait-for-spindle=1.23456" gcode = self.post.export()[0][1] split_gcode = gcode.splitlines() # print(f"--------{nl}{gcode}--------{nl}") - self.assertEqual(split_gcode[4], "M4 S3000") - self.assertEqual(split_gcode[5], "G4 P1.23456") + self.assertEqual(split_gcode[3], "M4 S3000") + self.assertEqual(split_gcode[4], "G4 P1.23456") diff --git a/src/Mod/CAM/CAMTests/TestRefactoredTestPostGCodes.py b/src/Mod/CAM/CAMTests/TestRefactoredTestPostGCodes.py index edeb10e442..aff6c073de 100644 --- a/src/Mod/CAM/CAMTests/TestRefactoredTestPostGCodes.py +++ b/src/Mod/CAM/CAMTests/TestRefactoredTestPostGCodes.py @@ -103,8 +103,8 @@ class TestRefactoredTestPostGCodes(PathTestUtils.PathTestBase): gcode = self.post.export()[0][1] if debug: print(f"--------{nl}{gcode}--------{nl}") - # there are 4 lines of "other stuff" before the line we are interested in - self.assertEqual(gcode.splitlines()[4], expected) + # there are 3 lines of "other stuff" before the line we are interested in + self.assertEqual(gcode.splitlines()[3], expected) def multi_compare(self, path, expected, args, debug=False): """Perform a test with multiple lines of gcode comparison.""" @@ -726,7 +726,6 @@ class TestRefactoredTestPostGCodes(PathTestUtils.PathTestBase): """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -742,7 +741,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -823,7 +821,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -839,7 +836,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -922,7 +918,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -938,7 +933,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -1001,7 +995,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -1017,7 +1010,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -1082,7 +1074,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -1098,7 +1089,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -1163,7 +1153,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -1179,7 +1168,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -1246,7 +1234,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -1262,7 +1249,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G90 @@ -1343,7 +1329,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -1359,7 +1344,6 @@ G90 """G90 G21 G54 -M6 T1 G0 X1.000 Y2.000 G0 Z8.000 G91 @@ -1791,7 +1775,6 @@ G90 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X20.000 Y30.000 Z10.000 A70.000 B80.000 C90.000 U40.000 V50.000 W60.000 F74.074 @@ -1799,7 +1782,6 @@ G1 X20.000 Y30.000 Z10.000 A70.000 B80.000 C90.000 U40.000 V50.000 W60.000 F74.0 """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F74.0736 G1 X0.7874 Y1.1811 Z0.3937 A70.0000 B80.0000 C90.0000 U1.5748 V1.9685 W2.3622 F2.9163 @@ -1814,14 +1796,12 @@ G1 X0.7874 Y1.1811 Z0.3937 A70.0000 B80.0000 C90.0000 U1.5748 V1.9685 W2.3622 F2 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X20.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.7874 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 """, @@ -1835,14 +1815,12 @@ G1 X0.7874 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y30.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y1.1811 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 """, @@ -1856,14 +1834,12 @@ G1 X0.3937 Y1.1811 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z10.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z0.3937 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 """, @@ -1877,14 +1853,12 @@ G1 X0.3937 Y0.7874 Z0.3937 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z30.000 A70.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A70.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F74.0736 """, @@ -1898,14 +1872,12 @@ G1 X0.3937 Y0.7874 Z1.1811 A70.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F7 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z30.000 A40.000 B80.000 C60.000 U70.000 V80.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B80.0000 C60.0000 U2.7559 V3.1496 W3.5433 F74.0736 """, @@ -1919,14 +1891,12 @@ G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B80.0000 C60.0000 U2.7559 V3.1496 W3.5433 F7 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C90.000 U70.000 V80.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C90.0000 U2.7559 V3.1496 W3.5433 F74.0736 """, @@ -1940,14 +1910,12 @@ G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C90.0000 U2.7559 V3.1496 W3.5433 F7 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U40.000 V80.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U1.5748 V3.1496 W3.5433 F2.9163 """, @@ -1961,14 +1929,12 @@ G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U1.5748 V3.1496 W3.5433 F2 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V50.000 W90.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V1.9685 W3.5433 F2.9163 """, @@ -1982,14 +1948,12 @@ G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V1.9685 W3.5433 F2 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 U70.000 V80.000 W60.000 F74.074 """, """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W2.3622 F2.9163 """, @@ -2004,7 +1968,6 @@ G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W2.3622 F2 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 F74.074 G1 X10.000 Y20.000 Z30.000 F74.074 G1 X20.000 Y30.000 Z10.000 F74.074 @@ -2012,7 +1975,6 @@ G1 X20.000 Y30.000 Z10.000 F74.074 """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 F2.9163 G1 X0.7874 Y1.1811 Z0.3937 F2.9163 @@ -2028,7 +1990,6 @@ G1 X0.7874 Y1.1811 Z0.3937 F2.9163 """G90 G21 G54 -M6 T1 G1 U70.000 V80.000 W90.000 F74.074 G1 U70.000 V80.000 W90.000 F74.074 G1 U40.000 V50.000 W60.000 F74.074 @@ -2036,7 +1997,6 @@ G1 U40.000 V50.000 W60.000 F74.074 """G90 G20 G54 -M6 T1 G1 U2.7559 V3.1496 W3.5433 F2.9163 G1 U2.7559 V3.1496 W3.5433 F2.9163 G1 U1.5748 V1.9685 W2.3622 F2.9163 @@ -2052,7 +2012,6 @@ G1 U1.5748 V1.9685 W2.3622 F2.9163 """G90 G21 G54 -M6 T1 G1 A40.000 B50.000 C60.000 F74.074 G1 A40.000 B50.000 C60.000 F74.074 G1 A70.000 B80.000 C90.000 F74.074 @@ -2060,7 +2019,6 @@ G1 A70.000 B80.000 C90.000 F74.074 """G90 G20 G54 -M6 T1 G1 A40.0000 B50.0000 C60.0000 F74.0736 G1 A40.0000 B50.0000 C60.0000 F74.0736 G1 A70.0000 B80.0000 C90.0000 F74.0736 @@ -2076,7 +2034,6 @@ G1 A70.0000 B80.0000 C90.0000 F74.0736 """G90 G21 G54 -M6 T1 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 F74.074 G1 X10.000 Y20.000 Z30.000 A40.000 B50.000 C60.000 F74.074 G1 X20.000 Y30.000 Z10.000 A70.000 B80.000 C90.000 F74.074 @@ -2084,7 +2041,6 @@ G1 X20.000 Y30.000 Z10.000 A70.000 B80.000 C90.000 F74.074 """G90 G20 G54 -M6 T1 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 F2.9163 G1 X0.3937 Y0.7874 Z1.1811 A40.0000 B50.0000 C60.0000 F74.0736 G1 X0.7874 Y1.1811 Z0.3937 A70.0000 B80.0000 C90.0000 F2.9163 @@ -2100,7 +2056,6 @@ G1 X0.7874 Y1.1811 Z0.3937 A70.0000 B80.0000 C90.0000 F2.9163 """G90 G21 G54 -M6 T1 G1 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 A40.000 B50.000 C60.000 U70.000 V80.000 W90.000 F74.074 G1 A70.000 B80.000 C90.000 U40.000 V50.000 W60.000 F74.074 @@ -2108,7 +2063,6 @@ G1 A70.000 B80.000 C90.000 U40.000 V50.000 W60.000 F74.074 """G90 G20 G54 -M6 T1 G1 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F2.9163 G1 A40.0000 B50.0000 C60.0000 U2.7559 V3.1496 W3.5433 F74.0736 G1 A70.0000 B80.0000 C90.0000 U1.5748 V1.9685 W2.3622 F2.9163 @@ -2124,7 +2078,6 @@ G1 A70.0000 B80.0000 C90.0000 U1.5748 V1.9685 W2.3622 F2.9163 """G90 G21 G54 -M6 T1 G1 X10.000 A40.000 F74.074 G1 X10.000 A40.000 F74.074 G1 X20.000 A70.000 F74.074 @@ -2132,7 +2085,6 @@ G1 X20.000 A70.000 F74.074 """G90 G20 G54 -M6 T1 G1 X0.3937 A40.0000 F2.9163 G1 X0.3937 A40.0000 F74.0736 G1 X0.7874 A70.0000 F2.9163 @@ -2148,7 +2100,6 @@ G1 X0.7874 A70.0000 F2.9163 """G90 G21 G54 -M6 T1 G1 A40.000 U70.000 F74.074 G1 A40.000 U70.000 F74.074 G1 A70.000 U40.000 F74.074 @@ -2156,7 +2107,6 @@ G1 A70.000 U40.000 F74.074 """G90 G20 G54 -M6 T1 G1 A40.0000 U2.7559 F2.9163 G1 A40.0000 U2.7559 F74.0736 G1 A70.0000 U1.5748 F2.9163 @@ -2172,7 +2122,6 @@ G1 A70.0000 U1.5748 F2.9163 """G90 G21 G54 -M6 T1 G1 A40.000 F74.074 G1 A40.000 F74.074 G1 A70.000 F74.074 @@ -2180,7 +2129,6 @@ G1 A70.000 F74.074 """G90 G20 G54 -M6 T1 G1 A40.0000 F74.0736 G1 A40.0000 F74.0736 G1 A70.0000 F74.0736 diff --git a/src/Mod/CAM/CAMTests/TestRefactoredTestPostMCodes.py b/src/Mod/CAM/CAMTests/TestRefactoredTestPostMCodes.py index 8692fda619..916dd92e62 100644 --- a/src/Mod/CAM/CAMTests/TestRefactoredTestPostMCodes.py +++ b/src/Mod/CAM/CAMTests/TestRefactoredTestPostMCodes.py @@ -103,8 +103,8 @@ class TestRefactoredTestPostMCodes(PathTestUtils.PathTestBase): gcode = self.post.export()[0][1] if debug: print(f"--------{nl}{gcode}--------{nl}") - # there are 4 lines of "other stuff" before the line we are interested in - self.assertEqual(gcode.splitlines()[4], expected) + # there are 3 lines of "other stuff" before the line we are interested in + self.assertEqual(gcode.splitlines()[3], expected) ############################################################################# # @@ -162,8 +162,26 @@ class TestRefactoredTestPostMCodes(PathTestUtils.PathTestBase): def test20060(self): """Test M6 command Generation.""" - self.single_compare("M6", "M6", "") - self.single_compare("M06", "M06", "") + + c = Path.Command("M6 T2") + + self.profile_op.Path = Path.Path([c]) + + self.job.PostProcessorArgs = "--tool_change" + gcode = self.post.export()[0][1] + split_gcode = gcode.splitlines() + # print(f"--------{nl}{gcode}--------{nl}") + self.assertEqual(split_gcode[4], "M6 T2") + + c = Path.Command("M06 T02") + + self.profile_op.Path = Path.Path([c]) + + self.job.PostProcessorArgs = "--tool_change" + gcode = self.post.export()[0][1] + split_gcode = gcode.splitlines() + # print(f"--------{nl}{gcode}--------{nl}") + self.assertEqual(split_gcode[4], "M06 T2") ############################################################################# diff --git a/src/Mod/CAM/Path/Post/UtilsParse.py b/src/Mod/CAM/Path/Post/UtilsParse.py index bf31a103d2..ec2808b706 100644 --- a/src/Mod/CAM/Path/Post/UtilsParse.py +++ b/src/Mod/CAM/Path/Post/UtilsParse.py @@ -174,11 +174,12 @@ def check_for_tool_change( gcode.append(f"{linenumber(values)}M5{nl}") for line in values["TOOL_CHANGE"].splitlines(False): gcode.append(f"{linenumber(values)}{line}{nl}") - elif values["OUTPUT_COMMENTS"]: + return False + if values["OUTPUT_COMMENTS"]: # convert the tool change to a comment comment = create_comment(values, format_command_line(values, command_line)) gcode.append(f"{linenumber(values)}{comment}{nl}") - return True + return True return False