From 6eb5181852d73421b997be619015038ff4934879 Mon Sep 17 00:00:00 2001 From: clsergent Date: Mon, 3 Mar 2025 22:49:42 +0100 Subject: [PATCH] Update UtilsParse.py Fixed an error where strings were added to a list (gcode) using the addition assignment operator ('+=') rather than the 'list.append' method, resulting in adding every character as a list member --- src/Mod/CAM/Path/Post/UtilsParse.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Mod/CAM/Path/Post/UtilsParse.py b/src/Mod/CAM/Path/Post/UtilsParse.py index 66614d4ae0..4ef8ceac74 100644 --- a/src/Mod/CAM/Path/Post/UtilsParse.py +++ b/src/Mod/CAM/Path/Post/UtilsParse.py @@ -88,7 +88,7 @@ def check_for_drill_translate( + format_command_line(values, command_line) + values["COMMAND_SPACE"], ) - gcode += f"{linenumber(values)}{comment}{nl}" + gcode.append(f"{linenumber(values)}{comment}{nl}") # wrap this block to ensure that the value of values["MOTION_MODE"] # is restored in case of error try: @@ -121,7 +121,7 @@ def check_for_machine_specific_commands(values: Values, gcode: Gcode, command: s if m: raw_command = m.group(1) # pass literally to the controller - gcode += f"{linenumber(values)}{raw_command}{nl}" + gcode.append(f"{linenumber(values)}{raw_command}{nl}") def check_for_spindle_wait( @@ -132,9 +132,9 @@ def check_for_spindle_wait( nl: str = "\n" if values["SPINDLE_WAIT"] > 0 and command in ("M3", "M03", "M4", "M04"): - gcode += f"{linenumber(values)}{format_command_line(values, command_line)}{nl}" + gcode.append(f"{linenumber(values)}{format_command_line(values, command_line)}{nl}") cmd = format_command_line(values, ["G4", f'P{values["SPINDLE_WAIT"]}']) - gcode += f"{linenumber(values)}{cmd}{nl}" + gcode.append(f"{linenumber(values)}{cmd}{nl}") def check_for_suppressed_commands( @@ -153,7 +153,7 @@ def check_for_suppressed_commands( + format_command_line(values, command_line) + values["COMMAND_SPACE"], ) - gcode += f"{linenumber(values)}{comment}{nl}" + gcode.append(f"{linenumber(values)}{comment}{nl}") # remove the command return True return False @@ -165,7 +165,7 @@ def check_for_tlo(values: Values, gcode: Gcode, command: str, params: PathParame if command in ("M6", "M06") and values["USE_TLO"]: cmd = format_command_line(values, ["G43", f'H{str(int(params["T"]))}']) - gcode += f"{linenumber(values)}{cmd}{nl}" + gcode.append(f"{linenumber(values)}{cmd}{nl}") def check_for_tool_change( @@ -177,13 +177,13 @@ def check_for_tool_change( if command in ("M6", "M06"): if values["OUTPUT_COMMENTS"]: comment = create_comment(values, "Begin toolchange") - gcode += f"{linenumber(values)}{comment}{nl}" + gcode.append(f"{linenumber(values)}{comment}{nl}") if values["OUTPUT_TOOL_CHANGE"]: if values["STOP_SPINDLE_FOR_TOOL_CHANGE"]: # stop the spindle - gcode += f"{linenumber(values)}M5{nl}" + gcode.append(f"{linenumber(values)}M5{nl}") for line in values["TOOL_CHANGE"].splitlines(False): - gcode += f"{linenumber(values)}{line}{nl}" + gcode.append(f"{linenumber(values)}{line}{nl}") elif values["OUTPUT_COMMENTS"]: # convert the tool change to a comment comment = create_comment( @@ -192,7 +192,7 @@ def check_for_tool_change( + format_command_line(values, command_line) + values["COMMAND_SPACE"], ) - gcode += f"{linenumber(values)}{comment}{nl}" + gcode.append(f"{linenumber(values)}{comment}{nl}") return True return False @@ -676,7 +676,7 @@ def parse_a_group(values: Values, gcode: Gcode, pathobj) -> None: if hasattr(pathobj, "Group"): # We have a compound or project. if values["OUTPUT_COMMENTS"]: comment = create_comment(values, f"Compound: {pathobj.Label}") - gcode += f"{linenumber(values)}{comment}{nl}" + gcode.append(f"{linenumber(values)}{comment}{nl}") for p in pathobj.Group: parse_a_group(values, gcode, p) else: # parsing simple path @@ -685,7 +685,7 @@ def parse_a_group(values: Values, gcode: Gcode, pathobj) -> None: return if values["OUTPUT_PATH_LABELS"] and values["OUTPUT_COMMENTS"]: comment = create_comment(values, f"Path: {pathobj.Label}") - gcode += f"{linenumber(values)}{comment}{nl}" + gcode.append(f"{linenumber(values)}{comment}{nl}") parse_a_path(values, gcode, pathobj) @@ -799,12 +799,12 @@ def parse_a_path(values: Values, gcode: Gcode, pathobj) -> None: command_line[0], ] # swap the order of the commands # Add a line number to the front and a newline to the end of the command line - gcode += ( + gcode.append( f"{linenumber(values)}{format_command_line(values, swapped_command_line)}{nl}" ) else: # Add a line number to the front and a newline to the end of the command line - gcode += f"{linenumber(values)}{format_command_line(values, command_line)}{nl}" + gcode.append(f"{linenumber(values)}{format_command_line(values, command_line)}{nl}") check_for_tlo(values, gcode, command, c.Parameters) check_for_machine_specific_commands(values, gcode, command)