CAM: Added three options to the refactored postprocessors

with tests.

Removed extra spaces in comments to work around auto-fix
removal of spaces at the end of lines in multi-line python strings.
This commit is contained in:
Lawrence Woestman
2025-03-02 15:49:46 -08:00
committed by Chris Hennes
parent b86c7c4a8f
commit 1fecb21db7
5 changed files with 309 additions and 56 deletions

View File

@@ -88,10 +88,13 @@ def init_argument_defaults(argument_defaults: Dict[str, bool]) -> None:
def init_arguments_visible(arguments_visible: Dict[str, bool]) -> None:
"""Initialize the flags for which arguments are visible in the arguments tooltip."""
arguments_visible["bcnc"] = False
arguments_visible["axis-modal"] = True
arguments_visible["axis-precision"] = True
arguments_visible["bcnc"] = False
arguments_visible["chipbreaking_amount"] = False
arguments_visible["command_space"] = False
arguments_visible["comments"] = True
arguments_visible["comment_symbol"] = False
arguments_visible["feed-precision"] = True
arguments_visible["header"] = True
arguments_visible["line-numbers"] = True
@@ -167,6 +170,29 @@ def init_shared_arguments(
"Suppress bCNC block header output",
arguments_visible["bcnc"],
)
if arguments_visible["chipbreaking_amount"]:
help_message = (
"Amount to move for chipbreaking in a translated G73 command, "
f'default is {str(values["CHIPBREAKING_AMOUNT"])}'
)
else:
help_message = argparse.SUPPRESS
shared.add_argument(
"--chipbreaking_amount",
help=help_message,
)
if arguments_visible["command_space"]:
help_message = (
"The character to use between parts of a command, "
"default is a space, may also use a null string"
)
else:
help_message = argparse.SUPPRESS
shared.add_argument(
"--command_space",
default=" ",
help=help_message,
)
add_flag_type_arguments(
shared,
argument_defaults["comments"],
@@ -176,6 +202,16 @@ def init_shared_arguments(
"Suppress comment output",
arguments_visible["comments"],
)
if arguments_visible["comment_symbol"]:
help_message = (
f'The character used to start a comment, default is "{values["COMMENT_SYMBOL"]}"'
)
else:
help_message = argparse.SUPPRESS
shared.add_argument(
"--comment_symbol",
help=help_message,
)
if arguments_visible["feed-precision"]:
help_message = (
f"Number of digits of precision for feed rate, "
@@ -680,10 +716,15 @@ def process_shared_arguments(
values["OUTPUT_BCNC"] = True
if args.no_bcnc:
values["OUTPUT_BCNC"] = False
if args.chipbreaking_amount:
values["CHIPBREAKING_AMOUNT"] = Units.parseQuantity(args.chipbreaking_amount)
values["COMMAND_SPACE"] = args.command_space
if args.comments:
values["OUTPUT_COMMENTS"] = True
if args.no_comments:
values["OUTPUT_COMMENTS"] = False
if args.comment_symbol:
values["COMMENT_SYMBOL"] = args.comment_symbol
if args.header:
values["OUTPUT_HEADER"] = True
if args.no_header:

View File

@@ -82,12 +82,7 @@ def check_for_drill_translate(
if values["TRANSLATE_DRILL_CYCLES"] and command in values["DRILL_CYCLES_TO_TRANSLATE"]:
if values["OUTPUT_COMMENTS"]: # Comment the original command
comment = create_comment(
values,
values["COMMAND_SPACE"]
+ format_command_line(values, command_line)
+ values["COMMAND_SPACE"],
)
comment = create_comment(values, format_command_line(values, command_line))
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
@@ -147,12 +142,7 @@ def check_for_suppressed_commands(
if command in values["SUPPRESS_COMMANDS"]:
if values["OUTPUT_COMMENTS"]:
# convert the command to a comment
comment = create_comment(
values,
values["COMMAND_SPACE"]
+ format_command_line(values, command_line)
+ values["COMMAND_SPACE"],
)
comment = create_comment(values, format_command_line(values, command_line))
gcode.append(f"{linenumber(values)}{comment}{nl}")
# remove the command
return True
@@ -186,12 +176,7 @@ def check_for_tool_change(
gcode.append(f"{linenumber(values)}{line}{nl}")
elif values["OUTPUT_COMMENTS"]:
# convert the tool change to a comment
comment = create_comment(
values,
values["COMMAND_SPACE"]
+ format_command_line(values, command_line)
+ values["COMMAND_SPACE"],
)
comment = create_comment(values, format_command_line(values, command_line))
gcode.append(f"{linenumber(values)}{comment}{nl}")
return True
return False