diff --git a/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py b/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py index 58b05f44a6..a074abb58d 100644 --- a/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py +++ b/src/Mod/CAM/CAMTests/TestRefactoredTestPost.py @@ -667,6 +667,42 @@ G54 ############################################################################# + def test00191(self): + """Make sure postprocessor doesn't crash on blank lines""" + + path = [ + Path.Command("G0 X1"), + Path.Command(""), + Path.Command("G0 X2"), + ] + + self.post.values["OUTPUT_BLANK_LINES"] = True + self.multi_compare( + path, + """G90 +G21 +G54 +G0 X1.000 + +G0 X2.000 +""", + "", + ) + + self.post.values["OUTPUT_BLANK_LINES"] = False + self.multi_compare( + path, + """G90 +G21 +G54 +G0 X1.000 +G0 X2.000 +""", + "", + ) + + ############################################################################# + def test00200(self): """Test Outputting visible arguments. diff --git a/src/Mod/CAM/Path/Post/UtilsArguments.py b/src/Mod/CAM/Path/Post/UtilsArguments.py index 7896d0a16d..f4ebd00517 100644 --- a/src/Mod/CAM/Path/Post/UtilsArguments.py +++ b/src/Mod/CAM/Path/Post/UtilsArguments.py @@ -478,6 +478,10 @@ def init_shared_values(values: Values) -> None: # values["OUTPUT_COMMENTS"] = True # + # If True output blank lines. If False blank lines are suppressed. + # + values["OUTPUT_BLANK_LINES"] = True + # # if False duplicate axis values or feeds are suppressed # if they are the same as the previous line. # diff --git a/src/Mod/CAM/Path/Post/UtilsParse.py b/src/Mod/CAM/Path/Post/UtilsParse.py index 7a09a70ae9..85cbed4cd4 100644 --- a/src/Mod/CAM/Path/Post/UtilsParse.py +++ b/src/Mod/CAM/Path/Post/UtilsParse.py @@ -719,6 +719,11 @@ def parse_a_path(values: Values, gcode: Gcode, pathobj) -> None: command = c.Name command_line = [] + # Skip blank lines if requested + if not command: + if not values["OUTPUT_BLANK_LINES"]: + continue + # Modify the command name if necessary if command.startswith("("): if not values["OUTPUT_COMMENTS"]: