| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | """ |
| | These are functions related to arguments and values for creating custom post processors. |
| | """ |
| | import argparse |
| | import os |
| | import shlex |
| | from typing import Any, Callable, Dict, Tuple, Union |
| |
|
| | from FreeCAD import Units |
| |
|
| | import Path.Post.UtilsParse as PostUtilsParse |
| |
|
| | |
| | PathParameter = float |
| | PathParameters = Dict[str, PathParameter] |
| | Parser = argparse.ArgumentParser |
| | Values = Dict[str, Any] |
| |
|
| | ParameterFunction = Callable[[Values, str, str, PathParameter, PathParameters], str] |
| |
|
| |
|
| | def add_flag_type_arguments( |
| | argument_group, |
| | default_flag: bool, |
| | true_argument: str, |
| | false_argument: str, |
| | true_help: str, |
| | false_help: str, |
| | visible: bool = True, |
| | ) -> None: |
| | """Create an argument specification for an argument that is a flag.""" |
| | if visible: |
| | if default_flag: |
| | true_help += " (default)" |
| | else: |
| | false_help += " (default)" |
| | else: |
| | true_help = false_help = argparse.SUPPRESS |
| | argument_group.add_argument(true_argument, action="store_true", help=true_help) |
| | argument_group.add_argument(false_argument, action="store_true", help=false_help) |
| |
|
| |
|
| | def init_argument_defaults(argument_defaults: Dict[str, bool]) -> None: |
| | """Initialize which argument to show as the default in flag-type arguments.""" |
| | argument_defaults["axis-modal"] = False |
| | argument_defaults["bcnc"] = False |
| | argument_defaults["comments"] = True |
| | argument_defaults["enable_coolant"] = False |
| | argument_defaults["enable_machine_specific_commands"] = False |
| | argument_defaults["header"] = True |
| | argument_defaults["line-numbers"] = False |
| | argument_defaults["list_tools_in_preamble"] = False |
| | argument_defaults["metric_inches"] = True |
| | argument_defaults["modal"] = False |
| | argument_defaults["output_all_arguments"] = False |
| | argument_defaults["output_machine_name"] = False |
| | argument_defaults["output_path_labels"] = False |
| | argument_defaults["output_visible_arguments"] = False |
| | argument_defaults["show-editor"] = True |
| | argument_defaults["split_arcs"] = False |
| | argument_defaults["tlo"] = True |
| | argument_defaults["tool_change"] = True |
| | argument_defaults["translate_drill"] = False |
| |
|
| |
|
| | def init_arguments_visible(arguments_visible: Dict[str, bool]) -> None: |
| | """Initialize the flags for which arguments are visible in the arguments tooltip.""" |
| | 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["enable_coolant"] = False |
| | arguments_visible["enable_machine_specific_commands"] = False |
| | arguments_visible["end_of_line_characters"] = False |
| | arguments_visible["feed-precision"] = True |
| | arguments_visible["finish_label"] = False |
| | arguments_visible["header"] = True |
| | arguments_visible["line_number_increment"] = False |
| | arguments_visible["line_number_start"] = False |
| | arguments_visible["line-numbers"] = True |
| | arguments_visible["list_tools_in_preamble"] = False |
| | arguments_visible["metric_inches"] = True |
| | arguments_visible["modal"] = True |
| | arguments_visible["output_all_arguments"] = True |
| | arguments_visible["output_machine_name"] = False |
| | arguments_visible["output_path_labels"] = False |
| | arguments_visible["output_visible_arguments"] = True |
| | arguments_visible["postamble"] = True |
| | arguments_visible["post_operation"] = False |
| | arguments_visible["preamble"] = True |
| | arguments_visible["precision"] = True |
| | arguments_visible["return-to"] = False |
| | arguments_visible["show-editor"] = True |
| | arguments_visible["split_arcs"] = True |
| | arguments_visible["tlo"] = True |
| | arguments_visible["tool_change"] = False |
| | arguments_visible["translate_drill"] = False |
| | arguments_visible["wait-for-spindle"] = False |
| |
|
| |
|
| | def init_shared_arguments( |
| | values: Values, |
| | argument_defaults: Dict[str, bool], |
| | arguments_visible: Dict[str, bool], |
| | ) -> Parser: |
| | """Initialize the arguments for postprocessors.""" |
| | help_message: str |
| | parser: Parser |
| | shared: argparse._ArgumentGroup |
| |
|
| | parser = argparse.ArgumentParser( |
| | prog=values["MACHINE_NAME"], usage=argparse.SUPPRESS, add_help=False |
| | ) |
| | shared = parser.add_argument_group("Arguments that are commonly used") |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["metric_inches"], |
| | "--metric", |
| | "--inches", |
| | "Convert output for Metric mode (G21)", |
| | "Convert output for US imperial mode (G20)", |
| | arguments_visible["metric_inches"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["axis-modal"], |
| | "--axis-modal", |
| | "--no-axis-modal", |
| | "Don't output axis values if they are the same as the previous line", |
| | "Output axis values even if they are the same as the previous line", |
| | arguments_visible["axis-modal"], |
| | ) |
| | if arguments_visible["axis-precision"]: |
| | help_message = ( |
| | f"Number of digits of precision for axis moves, " |
| | f'default is {str(values["DEFAULT_AXIS_PRECISION"])}' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument( |
| | "--axis-precision", |
| | default=-1, |
| | type=int, |
| | help=help_message, |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["bcnc"], |
| | "--bcnc", |
| | "--no-bcnc", |
| | ( |
| | "Add Job operations as bCNC block headers. " |
| | "Consider suppressing comments by adding --no-comments" |
| | ), |
| | "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"], |
| | "--comments", |
| | "--no-comments", |
| | "Output comments", |
| | "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, |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["enable_coolant"], |
| | "--enable_coolant", |
| | "--disable_coolant", |
| | "Enable coolant", |
| | "Disable coolant", |
| | arguments_visible["enable_coolant"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["enable_machine_specific_commands"], |
| | "--enable_machine_specific_commands", |
| | "--disable_machine_specific_commands", |
| | "Enable machine specific commands of the form (MC_RUN_COMMAND: blah)", |
| | "Disable machine specific commands", |
| | arguments_visible["enable_machine_specific_commands"], |
| | ) |
| | if arguments_visible["end_of_line_characters"]: |
| | help_message = ( |
| | "The character(s) to use at the end of each line in the output file, " |
| | "default is whatever the system uses, may also use '\\n', '\\r', or '\\r\\n'" |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument( |
| | "--end_of_line_characters", |
| | help=help_message, |
| | ) |
| | if arguments_visible["feed-precision"]: |
| | help_message = ( |
| | f"Number of digits of precision for feed rate, " |
| | f'default is {str(values["DEFAULT_FEED_PRECISION"])}' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument( |
| | "--feed-precision", |
| | default=-1, |
| | type=int, |
| | help=help_message, |
| | ) |
| | if arguments_visible["finish_label"]: |
| | help_message = ( |
| | "The characters to use in the 'Finish operation' comment, " |
| | f'default is "{values["FINISH_LABEL"]}"' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument( |
| | "--finish_label", |
| | help=help_message, |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["header"], |
| | "--header", |
| | "--no-header", |
| | "Output headers", |
| | "Suppress header output", |
| | arguments_visible["header"], |
| | ) |
| | if arguments_visible["line_number_increment"]: |
| | help_message = ( |
| | f'Amount to increment the line numbers, default is {str(values["LINE_INCREMENT"])}' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument( |
| | "--line_number_increment", |
| | default=-1, |
| | type=int, |
| | help=help_message, |
| | ) |
| | if arguments_visible["line_number_start"]: |
| | help_message = ( |
| | f'The number the line numbers start at, default is {str(values["line_number"])}' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument( |
| | "--line_number_start", |
| | default=-1, |
| | type=int, |
| | help=help_message, |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["line-numbers"], |
| | "--line-numbers", |
| | "--no-line-numbers", |
| | "Prefix with line numbers", |
| | "Don't prefix with line numbers", |
| | arguments_visible["line-numbers"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["list_tools_in_preamble"], |
| | "--list_tools_in_preamble", |
| | "--no-list_tools_in_preamble", |
| | "List the tools used in the operation in the preamble", |
| | "Don't list the tools used in the operation", |
| | arguments_visible["list_tools_in_preamble"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["modal"], |
| | "--modal", |
| | "--no-modal", |
| | "Don't output the G-command name if it is the same as the previous line", |
| | "Output the G-command name even if it is the same as the previous line", |
| | arguments_visible["modal"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["output_all_arguments"], |
| | "--output_all_arguments", |
| | "--no-output_all_arguments", |
| | "Output all of the available arguments", |
| | "Don't output all of the available arguments", |
| | arguments_visible["output_all_arguments"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["output_machine_name"], |
| | "--output_machine_name", |
| | "--no-output_machine_name", |
| | "Output the machine name in the pre-operation information", |
| | "Don't output the machine name in the pre-operation information", |
| | arguments_visible["output_machine_name"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["output_path_labels"], |
| | "--output_path_labels", |
| | "--no-output_path_labels", |
| | "Output Path labels at the beginning of each Path", |
| | "Don't output Path labels at the beginning of each Path", |
| | arguments_visible["output_path_labels"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["output_visible_arguments"], |
| | "--output_visible_arguments", |
| | "--no-output_visible_arguments", |
| | "Output all of the visible arguments", |
| | "Don't output the visible arguments", |
| | arguments_visible["output_visible_arguments"], |
| | ) |
| | if arguments_visible["postamble"]: |
| | help_message = ( |
| | f"Set commands to be issued after the last command, " |
| | f'default is "{values["POSTAMBLE"]}"' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument("--postamble", help=help_message) |
| | if arguments_visible["post_operation"]: |
| | help_message = ( |
| | f"Set commands to be issued after every operation, " |
| | f'default is "{values["POST_OPERATION"]}"' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument("--post_operation", help=help_message) |
| | if arguments_visible["preamble"]: |
| | help_message = ( |
| | f"Set commands to be issued before the first command, " |
| | f'default is "{values["PREAMBLE"]}"' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument("--preamble", help=help_message) |
| | |
| | |
| | |
| | |
| | if arguments_visible["precision"]: |
| | help_message = ( |
| | f"Number of digits of precision for both feed rate and axis " |
| | f'moves, default is {str(values["DEFAULT_AXIS_PRECISION"])} for metric or ' |
| | f'{str(values["DEFAULT_INCH_AXIS_PRECISION"])} for inches' |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument( |
| | "--precision", |
| | default=-1, |
| | type=int, |
| | help=help_message, |
| | ) |
| | if arguments_visible["return-to"]: |
| | help_message = ( |
| | "Move to the specified x,y,z coordinates at the end, e.g. " |
| | "--return-to=0,0,0 (default is do not move)" |
| | ) |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument("--return-to", default="", help=help_message) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["show-editor"], |
| | "--show-editor", |
| | "--no-show-editor", |
| | "Pop up editor before writing output", |
| | "Don't pop up editor before writing output", |
| | arguments_visible["show-editor"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["split_arcs"], |
| | "--split-arcs", |
| | "--no-split-arcs", |
| | "Convert G2/G3 arc commands to discrete G1 line segments", |
| | "Output G2/G3 arc commands as-is", |
| | arguments_visible["split_arcs"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["tlo"], |
| | "--tlo", |
| | "--no-tlo", |
| | "Output tool length offset (G43) following tool changes", |
| | "Suppress tool length offset (G43) following tool changes", |
| | arguments_visible["tlo"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["tool_change"], |
| | "--tool_change", |
| | "--no-tool_change", |
| | "Insert M6 and any other tool change G-code for all tool changes", |
| | "Convert M6 to a comment for all tool changes", |
| | arguments_visible["tool_change"], |
| | ) |
| | add_flag_type_arguments( |
| | shared, |
| | argument_defaults["translate_drill"], |
| | "--translate_drill", |
| | "--no-translate_drill", |
| | "Translate drill cycles G73, G81, G82 & G83 into G0/G1 movements", |
| | "Don't translate drill cycles G73, G81, G82 & G83 into G0/G1 movements", |
| | arguments_visible["translate_drill"], |
| | ) |
| | if arguments_visible["wait-for-spindle"]: |
| | help_message = "Time to wait (in seconds) after M3, M4 (default = 0.0)" |
| | else: |
| | help_message = argparse.SUPPRESS |
| | shared.add_argument("--wait-for-spindle", type=float, default=0.0, help=help_message) |
| | return parser |
| |
|
| |
|
| | def init_shared_values(values: Values) -> None: |
| | """Initialize the default values in postprocessors.""" |
| | |
| | |
| | |
| | values["AXIS_PRECISION"] = 3 |
| | |
| | |
| | |
| | |
| | values["CHIPBREAKING_AMOUNT"] = Units.Quantity(0.25, Units.Length) |
| |
|
| | |
| | |
| | |
| | values["COMMAND_SPACE"] = " " |
| | |
| | |
| | |
| | |
| | values["COMMENT_SYMBOL"] = "(" |
| | |
| | |
| | |
| | |
| | values["DEFAULT_AXIS_PRECISION"] = 3 |
| | |
| | |
| | |
| | values["DEFAULT_FEED_PRECISION"] = 3 |
| | |
| | |
| | |
| | values["DEFAULT_INCH_AXIS_PRECISION"] = 4 |
| | |
| | |
| | |
| | values["DEFAULT_INCH_FEED_PRECISION"] = 4 |
| | |
| | |
| | |
| | |
| | values["DRILL_CYCLES_TO_TRANSLATE"] = ["G73", "G81", "G82", "G83"] |
| | |
| | |
| | |
| | |
| | values["ENABLE_COOLANT"] = False |
| | |
| | |
| | |
| | |
| | values["ENABLE_MACHINE_SPECIFIC_COMMANDS"] = False |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | values["END_OF_LINE_CHARACTERS"] = "\n" |
| | |
| | |
| | |
| | values["FEED_PRECISION"] = 3 |
| | |
| | |
| | |
| | |
| | values["FINISH_LABEL"] = "Finish" |
| | |
| | |
| | |
| | values["LINE_INCREMENT"] = 10 |
| | |
| | |
| | |
| | values["line_number"] = 100 |
| | |
| | |
| | |
| | |
| | values["LIST_TOOLS_IN_PREAMBLE"] = False |
| | |
| | |
| | |
| | values["MACHINE_NAME"] = "unknown machine" |
| | |
| | |
| | |
| | |
| | values["MODAL"] = False |
| | |
| | |
| | |
| | values["MOTION_COMMANDS"] = [ |
| | "G0", |
| | "G00", |
| | "G1", |
| | "G01", |
| | "G2", |
| | "G02", |
| | "G3", |
| | "G03", |
| | ] |
| | |
| | |
| | |
| | |
| | values["MOTION_MODE"] = "G90" |
| | |
| | |
| | |
| | values["OUTPUT_ADAPTIVE"] = False |
| | |
| | |
| | |
| | values["OUTPUT_BCNC"] = False |
| | |
| | |
| | |
| | values["OUTPUT_COMMENTS"] = True |
| | |
| | |
| | |
| | values["OUTPUT_BLANK_LINES"] = True |
| | |
| | |
| | |
| | |
| | values["OUTPUT_DOUBLES"] = True |
| | |
| | |
| | |
| | values["OUTPUT_MACHINE_NAME"] = False |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | values["OUTPUT_HEADER"] = True |
| | |
| | |
| | |
| | |
| | values["OUTPUT_LINE_NUMBERS"] = False |
| | |
| | |
| | |
| | values["OUTPUT_PATH_LABELS"] = False |
| | |
| | |
| | |
| | |
| | |
| | |
| | values["OUTPUT_TOOL_CHANGE"] = True |
| | |
| | |
| | |
| | |
| | values["PARAMETER_FUNCTIONS"] = {} |
| | PostUtilsParse.init_parameter_functions(values["PARAMETER_FUNCTIONS"]) |
| | |
| | |
| | |
| | values["PARAMETER_ORDER"] = [ |
| | "D", |
| | "H", |
| | "L", |
| | "X", |
| | "Y", |
| | "Z", |
| | "A", |
| | "B", |
| | "C", |
| | "U", |
| | "V", |
| | "W", |
| | "I", |
| | "J", |
| | "K", |
| | "R", |
| | "P", |
| | "E", |
| | "Q", |
| | "F", |
| | "S", |
| | "T", |
| | ] |
| | |
| | |
| | |
| | |
| | values["POSTAMBLE"] = """""" |
| | |
| | |
| | |
| | values["POST_OPERATION"] = """""" |
| | |
| | |
| | |
| | |
| | values["PREAMBLE"] = """""" |
| | |
| | |
| | |
| | values["PRE_OPERATION"] = """""" |
| | |
| | |
| | |
| | values["RAPID_MOVES"] = ["G0", "G00"] |
| | |
| | |
| | |
| | |
| | |
| | values["RETURN_TO"] = None |
| | |
| | |
| | |
| | |
| | values["SAFETYBLOCK"] = """""" |
| | |
| | |
| | |
| | |
| | values["SHOW_EDITOR"] = True |
| | |
| | |
| | |
| | values["SPLIT_ARCS"] = False |
| | |
| | |
| | |
| | values["SHOW_MACHINE_UNITS"] = True |
| | |
| | |
| | |
| | |
| | values["SHOW_OPERATION_LABELS"] = True |
| | |
| | |
| | |
| | values["SPINDLE_DECIMALS"] = 0 |
| | |
| | |
| | |
| | |
| | values["SPINDLE_WAIT"] = 0.0 |
| | |
| | |
| | |
| | |
| | values["STOP_SPINDLE_FOR_TOOL_CHANGE"] = True |
| | |
| | |
| | |
| | |
| | values["SUPPRESS_COMMANDS"] = [] |
| | |
| | |
| | |
| | |
| | values["TOOL_CHANGE"] = """""" |
| | |
| | |
| | |
| | |
| | values["TOOLRETURN"] = """""" |
| | |
| | |
| | |
| | values["TRANSLATE_DRILL_CYCLES"] = False |
| | |
| | |
| | |
| | |
| | values["UNITS"] = "G21" |
| | values["UNIT_FORMAT"] = "mm" |
| | values["UNIT_SPEED_FORMAT"] = "mm/min" |
| | |
| | |
| | |
| | values["USE_TLO"] = True |
| |
|
| |
|
| | def process_shared_arguments( |
| | values: Values, |
| | parser: Parser, |
| | argstring: str, |
| | all_visible: Parser, |
| | filename: str, |
| | ) -> Tuple[bool, Union[None, str, argparse.Namespace]]: |
| | """Process the arguments to the postprocessor.""" |
| | args: argparse.Namespace |
| | argument_text: str |
| | v: str |
| |
|
| | try: |
| | args = parser.parse_args(shlex.split(argstring)) |
| | if args.output_all_arguments: |
| | argument_text = all_visible.format_help() |
| | if not filename == "-": |
| | with open( |
| | filename, |
| | "w", |
| | encoding="utf-8", |
| | ) as f: |
| | f.write(argument_text) |
| | return (False, argument_text) |
| | if args.output_visible_arguments: |
| | argument_text = parser.format_help() |
| | if not filename == "-": |
| | with open( |
| | filename, |
| | "w", |
| | encoding="utf-8", |
| | ) as f: |
| | f.write(argument_text) |
| | return (False, argument_text) |
| | |
| | values["UNITS"] = "G21" |
| | if args.metric: |
| | values["UNITS"] = "G21" |
| | if args.inches: |
| | values["UNITS"] = "G20" |
| | if values["UNITS"] == "G21": |
| | values["UNIT_FORMAT"] = "mm" |
| | values["UNIT_SPEED_FORMAT"] = "mm/min" |
| | elif values["UNITS"] == "G20": |
| | values["UNIT_FORMAT"] = "in" |
| | values["UNIT_SPEED_FORMAT"] = "in/min" |
| | |
| | |
| | |
| | |
| | if args.axis_precision != -1: |
| | values["AXIS_PRECISION"] = args.axis_precision |
| | elif args.precision != -1: |
| | values["AXIS_PRECISION"] = args.precision |
| | else: |
| | if values["UNITS"] == "G21": |
| | values["AXIS_PRECISION"] = values["DEFAULT_AXIS_PRECISION"] |
| | if values["UNITS"] == "G20": |
| | values["AXIS_PRECISION"] = values["DEFAULT_INCH_AXIS_PRECISION"] |
| | |
| | |
| | if args.feed_precision != -1: |
| | values["FEED_PRECISION"] = args.feed_precision |
| | elif args.precision != -1: |
| | values["FEED_PRECISION"] = args.precision |
| | else: |
| | if values["UNITS"] == "G21": |
| | values["FEED_PRECISION"] = values["DEFAULT_FEED_PRECISION"] |
| | elif values["UNITS"] == "G20": |
| | values["FEED_PRECISION"] = values["DEFAULT_INCH_FEED_PRECISION"] |
| | if args.axis_modal: |
| | values["OUTPUT_DOUBLES"] = False |
| | if args.no_axis_modal: |
| | values["OUTPUT_DOUBLES"] = True |
| | if args.bcnc: |
| | 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.enable_coolant: |
| | values["ENABLE_COOLANT"] = True |
| | if args.disable_coolant: |
| | values["ENABLE_COOLANT"] = False |
| | if args.enable_machine_specific_commands: |
| | values["ENABLE_MACHINE_SPECIFIC_COMMANDS"] = True |
| | if args.disable_machine_specific_commands: |
| | values["ENABLE_MACHINE_SPECIFIC_COMMANDS"] = False |
| | if args.end_of_line_characters: |
| | if args.end_of_line_characters == "\\n" or args.end_of_line_characters == "\n": |
| | values["END_OF_LINE_CHARACTERS"] = "\n\n" |
| | elif args.end_of_line_characters == "\\r" or args.end_of_line_characters == "\r": |
| | values["END_OF_LINE_CHARACTERS"] = "\r" |
| | elif args.end_of_line_characters == "\\r\\n" or args.end_of_line_characters == "\r\n": |
| | values["END_OF_LINE_CHARACTERS"] = "\r\n" |
| | else: |
| | print("invalid end_of_line_characters, ignoring") |
| | if args.finish_label: |
| | values["FINISH_LABEL"] = args.finish_label |
| | if args.header: |
| | values["OUTPUT_HEADER"] = True |
| | if args.no_header: |
| | values["OUTPUT_HEADER"] = False |
| | if args.line_number_increment != -1: |
| | values["LINE_INCREMENT"] = args.line_number_increment |
| | if args.line_number_start != -1: |
| | values["line_number"] = args.line_number_start |
| | if args.line_numbers: |
| | values["OUTPUT_LINE_NUMBERS"] = True |
| | if args.no_line_numbers: |
| | values["OUTPUT_LINE_NUMBERS"] = False |
| | if args.list_tools_in_preamble: |
| | values["LIST_TOOLS_IN_PREAMBLE"] = True |
| | if args.no_list_tools_in_preamble: |
| | values["LIST_TOOLS_IN_PREAMBLE"] = False |
| | if args.modal: |
| | values["MODAL"] = True |
| | if args.no_modal: |
| | values["MODAL"] = False |
| | if args.output_machine_name: |
| | values["OUTPUT_MACHINE_NAME"] = True |
| | if args.no_output_machine_name: |
| | values["OUTPUT_MACHINE_NAME"] = False |
| | if args.output_path_labels: |
| | values["OUTPUT_PATH_LABELS"] = True |
| | if args.no_output_path_labels: |
| | values["OUTPUT_PATH_LABELS"] = False |
| | if args.postamble is not None: |
| | values["POSTAMBLE"] = args.postamble.replace("\\n", "\n") |
| | if args.post_operation is not None: |
| | values["POST_OPERATION"] = args.post_operation.replace("\\n", "\n") |
| | if args.preamble is not None: |
| | values["PREAMBLE"] = args.preamble.replace("\\n", "\n") |
| | if args.return_to != "": |
| | values["RETURN_TO"] = [int(v) for v in args.return_to.split(",")] |
| | if len(values["RETURN_TO"]) != 3: |
| | values["RETURN_TO"] = None |
| | print("--return-to coordinates must be specified as <x>,<y>,<z>, ignoring") |
| | if args.show_editor: |
| | values["SHOW_EDITOR"] = True |
| | if args.no_show_editor: |
| | values["SHOW_EDITOR"] = False |
| | if args.split_arcs: |
| | values["SPLIT_ARCS"] = True |
| | if args.no_split_arcs: |
| | values["SPLIT_ARCS"] = False |
| | if args.tlo: |
| | values["USE_TLO"] = True |
| | if args.no_tlo: |
| | values["USE_TLO"] = False |
| | if args.tool_change: |
| | values["OUTPUT_TOOL_CHANGE"] = True |
| | if args.no_tool_change: |
| | values["OUTPUT_TOOL_CHANGE"] = False |
| | if args.translate_drill: |
| | values["TRANSLATE_DRILL_CYCLES"] = True |
| | if args.no_translate_drill: |
| | values["TRANSLATE_DRILL_CYCLES"] = False |
| | if args.wait_for_spindle > 0.0: |
| | values["SPINDLE_WAIT"] = args.wait_for_spindle |
| |
|
| | except (ArithmeticError, LookupError): |
| | return (False, None) |
| |
|
| | return (True, args) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|