Path: Reformatted to a line lenght of 88 using black.
This commit is contained in:
@@ -80,7 +80,9 @@ def processFileNameSubstitutions(
|
||||
if not D:
|
||||
D = "."
|
||||
else:
|
||||
FreeCAD.Console.PrintError("Please save document in order to resolve output path!\n")
|
||||
FreeCAD.Console.PrintError(
|
||||
"Please save document in order to resolve output path!\n"
|
||||
)
|
||||
return None
|
||||
outputpath = outputpath.replace("%D", D)
|
||||
|
||||
@@ -133,7 +135,9 @@ def processFileNameSubstitutions(
|
||||
if "%O" in filename and job.OrderOutputBy == "Operation":
|
||||
filename = filename.replace("%O", subpartname)
|
||||
|
||||
if "%S" in filename: # We always add a sequence number but the user can say where
|
||||
if (
|
||||
"%S" in filename
|
||||
): # We always add a sequence number but the user can say where
|
||||
filename = filename.replace("%S", str(sequencenumber))
|
||||
else:
|
||||
filename = f"{filename}-{sequencenumber}"
|
||||
@@ -208,9 +212,10 @@ def resolveFileName(job, subpartname, sequencenumber):
|
||||
# This section determines whether user interaction is necessary
|
||||
policy = PathPreferences.defaultOutputPolicy()
|
||||
|
||||
openDialog = (policy == "Open File Dialog")
|
||||
openDialog = policy == "Open File Dialog"
|
||||
# if os.path.isdir(filename) or not os.path.isdir(os.path.dirname(filename)):
|
||||
# # Either the entire filename resolves into a directory or the parent directory doesn't exist.
|
||||
# # Either the entire filename resolves into a directory or the parent
|
||||
# # directory doesn't exist.
|
||||
# # Either way I don't know what to do - ask for help
|
||||
# openDialog = True
|
||||
|
||||
@@ -252,7 +257,7 @@ def resolveFileName(job, subpartname, sequencenumber):
|
||||
def buildPostList(job):
|
||||
"""Takes the job and determines the specific objects and order to
|
||||
postprocess Returns a list of objects which can be passed to
|
||||
exportObjectsWith() for final posting"""
|
||||
exportObjectsWith() for final posting."""
|
||||
wcslist = job.Fixtures
|
||||
orderby = job.OrderOutputBy
|
||||
|
||||
@@ -260,8 +265,8 @@ def buildPostList(job):
|
||||
|
||||
if orderby == "Fixture":
|
||||
PathLog.debug("Ordering by Fixture")
|
||||
# Order by fixture means all operations and tool changes will be completed in one
|
||||
# fixture before moving to the next.
|
||||
# Order by fixture means all operations and tool changes will be
|
||||
# completed in one fixture before moving to the next.
|
||||
|
||||
currTool = None
|
||||
for index, f in enumerate(wcslist):
|
||||
@@ -273,7 +278,8 @@ def buildPostList(job):
|
||||
c2 = Path.Command(
|
||||
"G0 Z"
|
||||
+ str(
|
||||
job.Stock.Shape.BoundBox.ZMax + job.SetupSheet.ClearanceHeightOffset.Value
|
||||
job.Stock.Shape.BoundBox.ZMax
|
||||
+ job.SetupSheet.ClearanceHeightOffset.Value
|
||||
)
|
||||
)
|
||||
fobj.Path.addCommands(c2)
|
||||
@@ -308,7 +314,10 @@ def buildPostList(job):
|
||||
c1 = Path.Command(f)
|
||||
c2 = Path.Command(
|
||||
"G0 Z"
|
||||
+ str(job.Stock.Shape.BoundBox.ZMax + job.SetupSheet.ClearanceHeightOffset.Value)
|
||||
+ str(
|
||||
job.Stock.Shape.BoundBox.ZMax
|
||||
+ job.SetupSheet.ClearanceHeightOffset.Value
|
||||
)
|
||||
)
|
||||
fobj.Path = Path.Path([c1, c2])
|
||||
fobj.InList.append(job)
|
||||
@@ -408,7 +417,9 @@ def buildPostList(job):
|
||||
return postlist
|
||||
else:
|
||||
PathLog.track()
|
||||
finalpostlist = [("allitems", [item for slist in postlist for item in slist[1]])]
|
||||
finalpostlist = [
|
||||
("allitems", [item for slist in postlist for item in slist[1]])
|
||||
]
|
||||
return finalpostlist
|
||||
|
||||
|
||||
@@ -418,7 +429,9 @@ class DlgSelectPostProcessor:
|
||||
firstItem = None
|
||||
for post in PathPreferences.allEnabledPostProcessors():
|
||||
item = QtGui.QListWidgetItem(post)
|
||||
item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
item.setFlags(
|
||||
QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled
|
||||
)
|
||||
self.dialog.lwPostProcessor.addItem(item)
|
||||
if not firstItem:
|
||||
firstItem = item
|
||||
@@ -527,7 +540,9 @@ class CommandPathPost:
|
||||
|
||||
selected = FreeCADGui.Selection.getSelectionEx()
|
||||
if len(selected) > 1:
|
||||
FreeCAD.Console.PrintError("Please select a single job or other path object\n")
|
||||
FreeCAD.Console.PrintError(
|
||||
"Please select a single job or other path object\n"
|
||||
)
|
||||
return
|
||||
elif len(selected) == 1:
|
||||
sel = selected[0].Object
|
||||
|
||||
@@ -42,6 +42,7 @@ FreeCADGui = None
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
|
||||
|
||||
class GCodeHighlighter(QtGui.QSyntaxHighlighter):
|
||||
def __init__(self, parent=None):
|
||||
super(GCodeHighlighter, self).__init__(parent)
|
||||
@@ -177,7 +178,9 @@ def editor(gcode):
|
||||
FreeCAD.Console.PrintMessage(
|
||||
translate(
|
||||
"Path",
|
||||
"GCode size too big ({} o), disabling syntax highlighter.".format(gcodeSize),
|
||||
"GCode size too big ({} o), disabling syntax highlighter.".format(
|
||||
gcodeSize
|
||||
),
|
||||
)
|
||||
)
|
||||
result = dia.exec_()
|
||||
|
||||
@@ -36,7 +36,13 @@ import shlex
|
||||
|
||||
|
||||
def add_flag_type_arguments(
|
||||
argument_group, default_flag, true_argument, false_argument, true_help, false_help, visible=True
|
||||
argument_group,
|
||||
default_flag,
|
||||
true_argument,
|
||||
false_argument,
|
||||
true_help,
|
||||
false_help,
|
||||
visible=True,
|
||||
):
|
||||
if visible:
|
||||
if default_flag:
|
||||
@@ -50,7 +56,7 @@ def add_flag_type_arguments(
|
||||
|
||||
|
||||
def init_argument_defaults(argument_defaults):
|
||||
"""Initialize which argument to show as the default in flag-type arguments"""
|
||||
"""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
|
||||
@@ -91,7 +97,9 @@ def init_shared_arguments(values, argument_defaults, arguments_visible):
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=values["MACHINE_NAME"], usage=argparse.SUPPRESS, add_help=False
|
||||
)
|
||||
shared = parser.add_argument_group("Arguments that are shared with all postprocessors")
|
||||
shared = parser.add_argument_group(
|
||||
"Arguments that are shared with all postprocessors"
|
||||
)
|
||||
add_flag_type_arguments(
|
||||
shared,
|
||||
argument_defaults["metric_inches"],
|
||||
@@ -142,9 +150,8 @@ def init_shared_arguments(values, argument_defaults, arguments_visible):
|
||||
arguments_visible["comments"],
|
||||
)
|
||||
if arguments_visible["feed-precision"]:
|
||||
help_message = (
|
||||
"Number of digits of precision for feed rate, default is "
|
||||
+ str(values["DEFAULT_FEED_PRECISION"])
|
||||
help_message = "Number of digits of precision for feed rate, default is " + str(
|
||||
values["DEFAULT_FEED_PRECISION"]
|
||||
)
|
||||
else:
|
||||
help_message = argparse.SUPPRESS
|
||||
@@ -199,9 +206,10 @@ def init_shared_arguments(values, argument_defaults, arguments_visible):
|
||||
else:
|
||||
help_message = argparse.SUPPRESS
|
||||
shared.add_argument("--preamble", help=help_message)
|
||||
# The --precision argument is included for backwards compatibility with some postprocessors.
|
||||
# If both --axis-precision and --precision are provided, the --axis-precision value "wins".
|
||||
# If both --feed-precision and --precision are provided, the --feed-precision value "wins".
|
||||
# The --precision argument is included for backwards compatibility with
|
||||
# some postprocessors. If both --axis-precision and --precision are provided,
|
||||
# the --axis-precision value "wins". If both --feed-precision and --precision
|
||||
# are provided, the --feed-precision value "wins".
|
||||
if arguments_visible["precision"]:
|
||||
help_message = (
|
||||
"Number of digits of precision for both feed rate and axis moves, default is "
|
||||
@@ -263,7 +271,9 @@ def init_shared_arguments(values, argument_defaults, arguments_visible):
|
||||
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)
|
||||
shared.add_argument(
|
||||
"--wait-for-spindle", type=float, default=0.0, help=help_message
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
@@ -394,7 +404,8 @@ def init_shared_values(values):
|
||||
#
|
||||
values["OUTPUT_COMMENTS"] = True
|
||||
#
|
||||
# if False duplicate axis values are suppressed if they are the same as the previous line.
|
||||
# if False duplicate axis values are suppressed if they are the same as
|
||||
# the previous line.
|
||||
#
|
||||
values["OUTPUT_DOUBLES"] = True
|
||||
#
|
||||
@@ -616,7 +627,9 @@ def process_shared_arguments(values, parser, argstring):
|
||||
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")
|
||||
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:
|
||||
|
||||
@@ -74,7 +74,9 @@ def export_common(values, objectslist, filename):
|
||||
for obj in objectslist:
|
||||
if not hasattr(obj, "Path"):
|
||||
print(
|
||||
"The object " + obj.Name + " is not a path. Please select only path and Compounds."
|
||||
"The object "
|
||||
+ obj.Name
|
||||
+ " is not a path. Please select only path and Compounds."
|
||||
)
|
||||
return None
|
||||
|
||||
@@ -86,7 +88,9 @@ def export_common(values, objectslist, filename):
|
||||
|
||||
# write header
|
||||
if values["OUTPUT_HEADER"]:
|
||||
comment = PostUtilsParse.create_comment("Exported by FreeCAD", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Exported by FreeCAD", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Post Processor: " + values["POSTPROCESSOR_FILE_NAME"],
|
||||
@@ -97,7 +101,9 @@ def export_common(values, objectslist, filename):
|
||||
cam_file = os.path.basename(FreeCAD.ActiveDocument.FileName)
|
||||
else:
|
||||
cam_file = "<None>"
|
||||
comment = PostUtilsParse.create_comment("Cam File: " + cam_file, values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Cam File: " + cam_file, values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Output Time: " + str(datetime.datetime.now()), values["COMMENT_SYMBOL"]
|
||||
@@ -122,10 +128,13 @@ def export_common(values, objectslist, filename):
|
||||
item.Proxy, PathToolController.ToolController
|
||||
):
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"T{}={}".format(item.ToolNumber, item.Name), values["COMMENT_SYMBOL"]
|
||||
"T{}={}".format(item.ToolNumber, item.Name),
|
||||
values["COMMENT_SYMBOL"],
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
comment = PostUtilsParse.create_comment("Begin preamble", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Begin preamble", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
for line in values["PREAMBLE"].splitlines(False):
|
||||
gcode += PostUtilsParse.linenumber(values) + line + "\n"
|
||||
@@ -168,9 +177,13 @@ def export_common(values, objectslist, filename):
|
||||
"Block-name: " + obj.Label, values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
comment = PostUtilsParse.create_comment("Block-expand: 0", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Block-expand: 0", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
comment = PostUtilsParse.create_comment("Block-enable: 1", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Block-enable: 1", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
if values["OUTPUT_COMMENTS"]:
|
||||
if values["SHOW_OPERATION_LABELS"]:
|
||||
@@ -178,16 +191,20 @@ def export_common(values, objectslist, filename):
|
||||
"Begin operation: %s" % obj.Label, values["COMMENT_SYMBOL"]
|
||||
)
|
||||
else:
|
||||
comment = PostUtilsParse.create_comment("Begin operation", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Begin operation", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
if values["SHOW_MACHINE_UNITS"]:
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Machine units: %s" % values["UNIT_SPEED_FORMAT"], values["COMMENT_SYMBOL"]
|
||||
"Machine units: %s" % values["UNIT_SPEED_FORMAT"],
|
||||
values["COMMENT_SYMBOL"],
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
if values["OUTPUT_MACHINE_NAME"]:
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Machine: %s, %s" % (values["MACHINE_NAME"], values["UNIT_SPEED_FORMAT"]),
|
||||
"Machine: %s, %s"
|
||||
% (values["MACHINE_NAME"], values["UNIT_SPEED_FORMAT"]),
|
||||
values["COMMENT_SYMBOL"],
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
@@ -196,7 +213,11 @@ def export_common(values, objectslist, filename):
|
||||
|
||||
# get coolant mode
|
||||
coolantMode = "None"
|
||||
if hasattr(obj, "CoolantMode") or hasattr(obj, "Base") and hasattr(obj.Base, "CoolantMode"):
|
||||
if (
|
||||
hasattr(obj, "CoolantMode")
|
||||
or hasattr(obj, "Base")
|
||||
and hasattr(obj.Base, "CoolantMode")
|
||||
):
|
||||
if hasattr(obj, "CoolantMode"):
|
||||
coolantMode = obj.CoolantMode
|
||||
else:
|
||||
@@ -239,18 +260,28 @@ def export_common(values, objectslist, filename):
|
||||
gcode += PostUtilsParse.linenumber(values) + "M9" + "\n"
|
||||
|
||||
if values["RETURN_TO"]:
|
||||
gcode += PostUtilsParse.linenumber(values) + "G0 X%s Y%s Z%s\n" % tuple(values["RETURN_TO"])
|
||||
gcode += PostUtilsParse.linenumber(values) + "G0 X%s Y%s Z%s\n" % tuple(
|
||||
values["RETURN_TO"]
|
||||
)
|
||||
|
||||
# do the post_amble
|
||||
if values["OUTPUT_BCNC"]:
|
||||
comment = PostUtilsParse.create_comment("Block-name: post_amble", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Block-name: post_amble", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
comment = PostUtilsParse.create_comment("Block-expand: 0", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Block-expand: 0", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
comment = PostUtilsParse.create_comment("Block-enable: 1", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Block-enable: 1", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
if values["OUTPUT_COMMENTS"]:
|
||||
comment = PostUtilsParse.create_comment("Begin postamble", values["COMMENT_SYMBOL"])
|
||||
comment = PostUtilsParse.create_comment(
|
||||
"Begin postamble", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
gcode += PostUtilsParse.linenumber(values) + comment + "\n"
|
||||
for line in values["TOOLRETURN"].splitlines(False):
|
||||
gcode += PostUtilsParse.linenumber(values) + line + "\n"
|
||||
|
||||
@@ -76,7 +76,9 @@ def drill_translate(values, outstring, cmd, params):
|
||||
if RETRACT_Z < drill_Z:
|
||||
trBuff += (
|
||||
linenumber(values)
|
||||
+ create_comment("Drill cycle error: R less than Z", values["COMMENT_SYMBOL"])
|
||||
+ create_comment(
|
||||
"Drill cycle error: R less than Z", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
return trBuff
|
||||
@@ -100,20 +102,27 @@ def drill_translate(values, outstring, cmd, params):
|
||||
elif cmd == "G82":
|
||||
drill_DwellTime = params["P"]
|
||||
|
||||
# wrap this block to ensure machine's values["MOTION_MODE"] is restored in case of error
|
||||
# wrap this block to ensure machine's values["MOTION_MODE"] is restored
|
||||
# in case of error
|
||||
try:
|
||||
if values["MOTION_MODE"] == "G91":
|
||||
trBuff += linenumber(values) + "G90\n" # force absolute coordinates during cycles
|
||||
trBuff += (
|
||||
linenumber(values) + "G90\n"
|
||||
) # force absolute coordinates during cycles
|
||||
|
||||
strG0_RETRACT_Z = (
|
||||
"G0 Z"
|
||||
+ format(float(RETRACT_Z.getValueAs(values["UNIT_FORMAT"])), axis_precision_string)
|
||||
+ format(
|
||||
float(RETRACT_Z.getValueAs(values["UNIT_FORMAT"])),
|
||||
axis_precision_string,
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
strF_Feedrate = (
|
||||
" F"
|
||||
+ format(
|
||||
float(drill_feedrate.getValueAs(values["UNIT_SPEED_FORMAT"])), feed_precision_string
|
||||
float(drill_feedrate.getValueAs(values["UNIT_SPEED_FORMAT"])),
|
||||
feed_precision_string,
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
@@ -125,9 +134,13 @@ def drill_translate(values, outstring, cmd, params):
|
||||
trBuff += (
|
||||
linenumber(values)
|
||||
+ "G0 X"
|
||||
+ format(float(drill_X.getValueAs(values["UNIT_FORMAT"])), axis_precision_string)
|
||||
+ format(
|
||||
float(drill_X.getValueAs(values["UNIT_FORMAT"])), axis_precision_string
|
||||
)
|
||||
+ " Y"
|
||||
+ format(float(drill_Y.getValueAs(values["UNIT_FORMAT"])), axis_precision_string)
|
||||
+ format(
|
||||
float(drill_Y.getValueAs(values["UNIT_FORMAT"])), axis_precision_string
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
if values["CURRENT_Z"] > RETRACT_Z:
|
||||
@@ -136,7 +149,10 @@ def drill_translate(values, outstring, cmd, params):
|
||||
trBuff += (
|
||||
linenumber(values)
|
||||
+ "G1 Z"
|
||||
+ format(float(RETRACT_Z.getValueAs(values["UNIT_FORMAT"])), axis_precision_string)
|
||||
+ format(
|
||||
float(RETRACT_Z.getValueAs(values["UNIT_FORMAT"])),
|
||||
axis_precision_string,
|
||||
)
|
||||
+ strF_Feedrate
|
||||
)
|
||||
last_Stop_Z = RETRACT_Z
|
||||
@@ -146,7 +162,10 @@ def drill_translate(values, outstring, cmd, params):
|
||||
trBuff += (
|
||||
linenumber(values)
|
||||
+ "G1 Z"
|
||||
+ format(float(drill_Z.getValueAs(values["UNIT_FORMAT"])), axis_precision_string)
|
||||
+ format(
|
||||
float(drill_Z.getValueAs(values["UNIT_FORMAT"])),
|
||||
axis_precision_string,
|
||||
)
|
||||
+ strF_Feedrate
|
||||
)
|
||||
# pause where applicable
|
||||
@@ -164,7 +183,9 @@ def drill_translate(values, outstring, cmd, params):
|
||||
linenumber(values)
|
||||
+ "G0 Z"
|
||||
+ format(
|
||||
float(clearance_depth.getValueAs(values["UNIT_FORMAT"])),
|
||||
float(
|
||||
clearance_depth.getValueAs(values["UNIT_FORMAT"])
|
||||
),
|
||||
axis_precision_string,
|
||||
)
|
||||
+ "\n"
|
||||
@@ -243,7 +264,9 @@ def parse(values, pathobj):
|
||||
|
||||
if hasattr(pathobj, "Group"): # We have a compound or project.
|
||||
if values["OUTPUT_COMMENTS"]:
|
||||
comment = create_comment("Compound: " + pathobj.Label, values["COMMENT_SYMBOL"])
|
||||
comment = create_comment(
|
||||
"Compound: " + pathobj.Label, values["COMMENT_SYMBOL"]
|
||||
)
|
||||
out += linenumber(values) + comment + "\n"
|
||||
for p in pathobj.Group:
|
||||
out += parse(values, p)
|
||||
@@ -305,7 +328,9 @@ def parse(values, pathobj):
|
||||
if opHorizRapid and opVertRapid:
|
||||
command = "G1"
|
||||
else:
|
||||
outstring.append("(Tool Controller Rapid Values are unset)" + "\n")
|
||||
outstring.append(
|
||||
"(Tool Controller Rapid Values are unset)" + "\n"
|
||||
)
|
||||
|
||||
outstring.append(command)
|
||||
|
||||
@@ -318,16 +343,23 @@ def parse(values, pathobj):
|
||||
for param in values["PARAMETER_ORDER"]:
|
||||
if param in c.Parameters:
|
||||
if param == "F" and (
|
||||
currLocation[param] != c.Parameters[param] or values["OUTPUT_DOUBLES"]
|
||||
currLocation[param] != c.Parameters[param]
|
||||
or values["OUTPUT_DOUBLES"]
|
||||
):
|
||||
# centroid and linuxcnc don't use rapid speeds
|
||||
if command not in values["RAPID_MOVES"]:
|
||||
speed = Units.Quantity(c.Parameters["F"], FreeCAD.Units.Velocity)
|
||||
speed = Units.Quantity(
|
||||
c.Parameters["F"], FreeCAD.Units.Velocity
|
||||
)
|
||||
if speed.getValueAs(values["UNIT_SPEED_FORMAT"]) > 0.0:
|
||||
outstring.append(
|
||||
param
|
||||
+ format(
|
||||
float(speed.getValueAs(values["UNIT_SPEED_FORMAT"])),
|
||||
float(
|
||||
speed.getValueAs(
|
||||
values["UNIT_SPEED_FORMAT"]
|
||||
)
|
||||
),
|
||||
feed_precision_string,
|
||||
)
|
||||
)
|
||||
@@ -342,7 +374,9 @@ def parse(values, pathobj):
|
||||
outstring.append(
|
||||
param
|
||||
+ PostUtils.fmt(
|
||||
c.Parameters[param], values["SPINDLE_DECIMALS"], "G21"
|
||||
c.Parameters[param],
|
||||
values["SPINDLE_DECIMALS"],
|
||||
"G21",
|
||||
)
|
||||
)
|
||||
else: # anything else that is supported (G41.1?, G42.1?)
|
||||
@@ -350,10 +384,20 @@ def parse(values, pathobj):
|
||||
elif param == "P":
|
||||
if command in ["G2", "G02", "G3", "G03", "G5.2", "G5.3", "G10"]:
|
||||
outstring.append(param + str(int(c.Parameters[param])))
|
||||
elif command in ["G4", "G04", "G64", "G76", "G82", "G86", "G89"]:
|
||||
elif command in [
|
||||
"G4",
|
||||
"G04",
|
||||
"G64",
|
||||
"G76",
|
||||
"G82",
|
||||
"G86",
|
||||
"G89",
|
||||
]:
|
||||
outstring.append(param + str(float(c.Parameters[param])))
|
||||
elif command in ["G5", "G05"]:
|
||||
pos = Units.Quantity(c.Parameters[param], FreeCAD.Units.Length)
|
||||
pos = Units.Quantity(
|
||||
c.Parameters[param], FreeCAD.Units.Length
|
||||
)
|
||||
outstring.append(
|
||||
param
|
||||
+ format(
|
||||
@@ -366,7 +410,9 @@ def parse(values, pathobj):
|
||||
elif param == "S":
|
||||
outstring.append(
|
||||
param
|
||||
+ PostUtils.fmt(c.Parameters[param], values["SPINDLE_DECIMALS"], "G21")
|
||||
+ PostUtils.fmt(
|
||||
c.Parameters[param], values["SPINDLE_DECIMALS"], "G21"
|
||||
)
|
||||
)
|
||||
else:
|
||||
if (
|
||||
@@ -376,7 +422,9 @@ def parse(values, pathobj):
|
||||
):
|
||||
continue
|
||||
else:
|
||||
pos = Units.Quantity(c.Parameters[param], FreeCAD.Units.Length)
|
||||
pos = Units.Quantity(
|
||||
c.Parameters[param], FreeCAD.Units.Length
|
||||
)
|
||||
outstring.append(
|
||||
param
|
||||
+ format(
|
||||
@@ -392,7 +440,11 @@ def parse(values, pathobj):
|
||||
outstring.append(
|
||||
"F"
|
||||
+ format(
|
||||
float(opHorizRapid.getValueAs(values["UNIT_SPEED_FORMAT"])),
|
||||
float(
|
||||
opHorizRapid.getValueAs(
|
||||
values["UNIT_SPEED_FORMAT"]
|
||||
)
|
||||
),
|
||||
axis_precision_string,
|
||||
)
|
||||
)
|
||||
@@ -400,7 +452,11 @@ def parse(values, pathobj):
|
||||
outstring.append(
|
||||
"F"
|
||||
+ format(
|
||||
float(opVertRapid.getValueAs(values["UNIT_SPEED_FORMAT"])),
|
||||
float(
|
||||
opVertRapid.getValueAs(
|
||||
values["UNIT_SPEED_FORMAT"]
|
||||
)
|
||||
),
|
||||
axis_precision_string,
|
||||
)
|
||||
)
|
||||
@@ -413,11 +469,17 @@ def parse(values, pathobj):
|
||||
# and the withdrawal plan
|
||||
if command in values["MOTION_COMMANDS"]:
|
||||
if "X" in c.Parameters:
|
||||
values["CURRENT_X"] = Units.Quantity(c.Parameters["X"], FreeCAD.Units.Length)
|
||||
values["CURRENT_X"] = Units.Quantity(
|
||||
c.Parameters["X"], FreeCAD.Units.Length
|
||||
)
|
||||
if "Y" in c.Parameters:
|
||||
values["CURRENT_Y"] = Units.Quantity(c.Parameters["Y"], FreeCAD.Units.Length)
|
||||
values["CURRENT_Y"] = Units.Quantity(
|
||||
c.Parameters["Y"], FreeCAD.Units.Length
|
||||
)
|
||||
if "Z" in c.Parameters:
|
||||
values["CURRENT_Z"] = Units.Quantity(c.Parameters["Z"], FreeCAD.Units.Length)
|
||||
values["CURRENT_Z"] = Units.Quantity(
|
||||
c.Parameters["Z"], FreeCAD.Units.Length
|
||||
)
|
||||
|
||||
if command in ("G98", "G99"):
|
||||
values["DRILL_RETRACT_MODE"] = command
|
||||
@@ -433,10 +495,14 @@ def parse(values, pathobj):
|
||||
|
||||
if values["SPINDLE_WAIT"] > 0:
|
||||
if command in ("M3", "M03", "M4", "M04"):
|
||||
out += linenumber(values) + format_outstring(values, outstring) + "\n"
|
||||
out += (
|
||||
linenumber(values) + format_outstring(values, outstring) + "\n"
|
||||
)
|
||||
out += (
|
||||
linenumber(values)
|
||||
+ format_outstring(values, ["G4", "P%s" % values["SPINDLE_WAIT"]])
|
||||
+ format_outstring(
|
||||
values, ["G4", "P%s" % values["SPINDLE_WAIT"]]
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
outstring = []
|
||||
@@ -444,7 +510,9 @@ def parse(values, pathobj):
|
||||
# Check for Tool Change:
|
||||
if command in ("M6", "M06"):
|
||||
if values["OUTPUT_COMMENTS"]:
|
||||
comment = create_comment("Begin toolchange", values["COMMENT_SYMBOL"])
|
||||
comment = create_comment(
|
||||
"Begin toolchange", values["COMMENT_SYMBOL"]
|
||||
)
|
||||
out += linenumber(values) + comment + "\n"
|
||||
if values["OUTPUT_TOOL_CHANGE"]:
|
||||
if values["STOP_SPINDLE_FOR_TOOL_CHANGE"]:
|
||||
|
||||
Reference in New Issue
Block a user