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"]:
|
||||
|
||||
@@ -40,10 +40,10 @@ class TestCentroidPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -54,9 +54,10 @@ class TestCentroidPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does
|
||||
not have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
@@ -65,8 +66,8 @@ class TestCentroidPost(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -91,7 +92,8 @@ class TestCentroidPost(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
# header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing.
|
||||
# Only test length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 16)
|
||||
@@ -155,8 +157,6 @@ M99
|
||||
expected = "G0 X10.00 Y20.00 Z30.00"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
@@ -220,7 +220,7 @@ M99
|
||||
expected = "G0 X0.3937 Y0.7874 Z1.1811"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
args = ("--no-header --inches --axis-precision=2 --no-show-editor")
|
||||
args = "--no-header --inches --axis-precision=2 --no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
result = gcode.splitlines()[5]
|
||||
expected = "G0 X0.39 Y0.79 Z1.18"
|
||||
|
||||
@@ -38,10 +38,10 @@ class TestGrblPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -52,10 +52,11 @@ class TestGrblPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does
|
||||
not have access to the class `self` reference. This method is able
|
||||
to call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
|
||||
@@ -63,8 +64,8 @@ class TestGrblPost(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -89,7 +90,9 @@ class TestGrblPost(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
args = "--no-show-editor" # header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing. Only test
|
||||
# length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 13)
|
||||
|
||||
@@ -149,8 +152,6 @@ M2
|
||||
expected = "G0 X10.00 Y20.00 Z30.00"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
|
||||
@@ -38,10 +38,10 @@ class TestLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -52,10 +52,11 @@ class TestLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does
|
||||
not have access to the class `self` reference. This method is able
|
||||
to call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
|
||||
@@ -63,8 +64,8 @@ class TestLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -89,7 +90,9 @@ class TestLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
args = "--no-show-editor" # header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing.
|
||||
# Only test length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 13)
|
||||
|
||||
@@ -149,8 +152,6 @@ M2
|
||||
expected = "G0 X10.00 Y20.00 Z30.00 "
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
|
||||
@@ -40,10 +40,10 @@ class TestMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -54,10 +54,11 @@ class TestMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does
|
||||
not have access to the class `self` reference. This method is able
|
||||
to call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
|
||||
@@ -65,8 +66,8 @@ class TestMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -91,7 +92,8 @@ class TestMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
# header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing.
|
||||
# Only test length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 13)
|
||||
@@ -151,8 +153,6 @@ M2
|
||||
expected = "G0 X10.00 Y20.00 Z30.00"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
|
||||
@@ -80,7 +80,6 @@ G2 I-7.500000 J0.000000 X-2.500000 Y5.000000 Z18.000000\
|
||||
G2 I7.500000 J0.000000 X12.500000 Y5.000000 Z18.000000\
|
||||
G0 X5.000000 Y5.000000 Z18.000000G0 Z20.000000"
|
||||
|
||||
|
||||
def test00(self):
|
||||
"""Test Basic Helix Generator Return"""
|
||||
args = _resetArgs()
|
||||
@@ -118,7 +117,8 @@ G0 X5.000000 Y5.000000 Z18.000000G0 Z20.000000"
|
||||
args["tool_diameter"] = 5.0
|
||||
self.assertRaises(ValueError, generator.generate, **args)
|
||||
|
||||
# require tool fit 2: hole diameter not greater than tool diam with zero inner radius
|
||||
# require tool fit 2: hole diameter not greater than tool diam
|
||||
# with zero inner radius
|
||||
args["hole_radius"] = 2.0
|
||||
args["inner_radius"] = 0.0
|
||||
args["tool_diameter"] = 5.0
|
||||
|
||||
@@ -156,7 +156,10 @@ class TestPathPost(unittest.TestCase):
|
||||
)
|
||||
processor = PostProcessor.load(postprocessor_id)
|
||||
output_file_path = FreeCAD.getHomePath() + PATHTESTS_LOCATION
|
||||
output_file_pattern = "test_%s_%s" % (postprocessor_id, output_file_id)
|
||||
output_file_pattern = "test_%s_%s" % (
|
||||
postprocessor_id,
|
||||
output_file_id,
|
||||
)
|
||||
output_file_extension = ".ngc"
|
||||
for idx, section in enumerate(postlist):
|
||||
partname = section[0]
|
||||
@@ -173,23 +176,34 @@ class TestPathPost(unittest.TestCase):
|
||||
file_path, extension = os.path.splitext(output_filename)
|
||||
reference_file_name = "%s%s%s" % (file_path, "_ref", extension)
|
||||
# print("reference file: " + reference_file_name)
|
||||
gcode = processor.export(sublist, output_filename, postprocessor_arguments)
|
||||
gcode = processor.export(
|
||||
sublist, output_filename, postprocessor_arguments
|
||||
)
|
||||
if not gcode:
|
||||
print("no gcode")
|
||||
with open(reference_file_name, "r") as fp:
|
||||
reference_gcode = fp.read()
|
||||
if not reference_gcode:
|
||||
print("no reference gcode")
|
||||
# Remove the "Output Time:" line in the header from the comparison
|
||||
# if it is present because it changes with every test.
|
||||
gcode_lines = [i for i in gcode.splitlines(True) if "Output Time:" not in i]
|
||||
# Remove the "Output Time:" line in the header from the
|
||||
# comparison if it is present because it changes with
|
||||
# every test.
|
||||
gcode_lines = [
|
||||
i for i in gcode.splitlines(True) if "Output Time:" not in i
|
||||
]
|
||||
reference_gcode_lines = [
|
||||
i for i in reference_gcode.splitlines(True) if "Output Time:" not in i
|
||||
i
|
||||
for i in reference_gcode.splitlines(True)
|
||||
if "Output Time:" not in i
|
||||
]
|
||||
if gcode_lines != reference_gcode_lines:
|
||||
msg = "".join(difflib.ndiff(gcode_lines, reference_gcode_lines))
|
||||
msg = "".join(
|
||||
difflib.ndiff(gcode_lines, reference_gcode_lines)
|
||||
)
|
||||
self.fail(
|
||||
os.path.basename(output_filename) + " output doesn't match:\n" + msg
|
||||
os.path.basename(output_filename)
|
||||
+ " output doesn't match:\n"
|
||||
+ msg
|
||||
)
|
||||
if not KEEP_DEBUG_OUTPUT:
|
||||
os.remove(output_filename)
|
||||
@@ -214,11 +228,15 @@ class TestPathPostUtils(unittest.TestCase):
|
||||
|
||||
testpath = Path.Path(commands)
|
||||
self.assertTrue(len(testpath.Commands) == 9)
|
||||
self.assertTrue(len([c for c in testpath.Commands if c.Name in ["G2", "G3"]]) == 4)
|
||||
self.assertTrue(
|
||||
len([c for c in testpath.Commands if c.Name in ["G2", "G3"]]) == 4
|
||||
)
|
||||
|
||||
results = PostUtils.splitArcs(testpath)
|
||||
# self.assertTrue(len(results.Commands) == 117)
|
||||
self.assertTrue(len([c for c in results.Commands if c.Name in ["G2", "G3"]]) == 0)
|
||||
self.assertTrue(
|
||||
len([c for c in results.Commands if c.Name in ["G2", "G3"]]) == 0
|
||||
)
|
||||
|
||||
|
||||
def dumpgroup(group):
|
||||
@@ -392,7 +410,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
FreeCAD.setActiveDocument(self.doc.Label)
|
||||
teststring = ""
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
self.job.SplitOutput = False
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
|
||||
@@ -406,7 +426,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
# Test basic string substitution without splitting
|
||||
teststring = "~/Desktop/%j.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
self.job.SplitOutput = False
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
|
||||
@@ -414,24 +436,31 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
subpart, objs = outlist[0]
|
||||
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(os.path.normpath(filename), os.path.normpath("~/Desktop/MainJob.nc"))
|
||||
self.assertEqual(
|
||||
os.path.normpath(filename), os.path.normpath("~/Desktop/MainJob.nc")
|
||||
)
|
||||
|
||||
def test010(self):
|
||||
# Substitute current file path
|
||||
teststring = "%D/testfile.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(
|
||||
os.path.normpath(filename), os.path.normpath(f"{self.testfilepath}/testfile.nc")
|
||||
os.path.normpath(filename),
|
||||
os.path.normpath(f"{self.testfilepath}/testfile.nc"),
|
||||
)
|
||||
|
||||
def test020(self):
|
||||
teststring = "%d.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
@@ -440,7 +469,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
def test030(self):
|
||||
teststring = "%M/outfile.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
@@ -450,19 +481,24 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
# unused substitution strings should be ignored
|
||||
teststring = "%d%T%t%W%O/testdoc.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(
|
||||
os.path.normpath(filename), os.path.normpath(f"{self.testfilename}/testdoc.nc")
|
||||
os.path.normpath(filename),
|
||||
os.path.normpath(f"{self.testfilename}/testdoc.nc"),
|
||||
)
|
||||
|
||||
def test050(self):
|
||||
# explicitly using the sequence number should include it where indicated.
|
||||
teststring = "%S-%d.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
@@ -477,7 +513,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
# substitute jobname and use default sequence numbers
|
||||
teststring = "%j.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(filename, "MainJob-0.nc")
|
||||
@@ -488,7 +526,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
# Use Toolnumbers and default sequence numbers
|
||||
teststring = "%T.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
@@ -500,7 +540,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
# Use Tooldescriptions and default sequence numbers
|
||||
teststring = "%t.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
outlist = PathPost.buildPostList(self.job)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
@@ -517,7 +559,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
|
||||
teststring = "%j.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(filename, "MainJob-0.nc")
|
||||
@@ -527,7 +571,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
|
||||
teststring = "%W-%j.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(filename, "G54-MainJob-0.nc")
|
||||
@@ -543,7 +589,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
|
||||
teststring = "%j.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(filename, "MainJob-0.nc")
|
||||
@@ -553,7 +601,9 @@ class TestOutputNameSubstitution(unittest.TestCase):
|
||||
|
||||
teststring = "%O-%j.nc"
|
||||
self.job.PostProcessorOutputFile = teststring
|
||||
PathPreferences.setOutputFileDefaults(teststring, "Append Unique ID on conflict")
|
||||
PathPreferences.setOutputFileDefaults(
|
||||
teststring, "Append Unique ID on conflict"
|
||||
)
|
||||
subpart, objs = outlist[0]
|
||||
filename = PathPost.resolveFileName(self.job, subpart, 0)
|
||||
self.assertEqual(filename, "OutsideProfile-MainJob-0.nc")
|
||||
|
||||
@@ -40,10 +40,10 @@ class TestRefactoredCentroidPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -54,10 +54,11 @@ class TestRefactoredCentroidPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does not
|
||||
have access to the class `self` reference. This method is able to
|
||||
call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
|
||||
@@ -65,8 +66,8 @@ class TestRefactoredCentroidPost(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -91,7 +92,8 @@ class TestRefactoredCentroidPost(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
# header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing.
|
||||
# Only test length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 16)
|
||||
@@ -155,8 +157,6 @@ M99
|
||||
expected = "G0 X10.00 Y20.00 Z30.00"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
@@ -214,7 +214,7 @@ M99
|
||||
expected = "G0 X0.3937 Y0.7874 Z1.1811"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
args = ("--no-header --inches --axis-precision=2 --no-show-editor")
|
||||
args = "--no-header --inches --axis-precision=2 --no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
result = gcode.splitlines()[5]
|
||||
expected = "G0 X0.39 Y0.79 Z1.18"
|
||||
|
||||
@@ -40,10 +40,10 @@ class TestRefactoredGrblPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -54,9 +54,10 @@ class TestRefactoredGrblPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does not
|
||||
have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
@@ -65,8 +66,8 @@ class TestRefactoredGrblPost(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -91,7 +92,8 @@ class TestRefactoredGrblPost(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
# header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing.
|
||||
# Only test length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 14)
|
||||
@@ -151,8 +153,6 @@ M2
|
||||
expected = "G0 X10.00 Y20.00 Z30.00"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
@@ -210,7 +210,7 @@ M2
|
||||
expected = "G0 X0.3937 Y0.7874 Z1.1811"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
args = ("--no-header --inches --precision=2 --no-show-editor")
|
||||
args = "--no-header --inches --precision=2 --no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
result = gcode.splitlines()[5]
|
||||
expected = "G0 X0.39 Y0.79 Z1.18"
|
||||
|
||||
@@ -40,10 +40,10 @@ class TestRefactoredLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -54,9 +54,10 @@ class TestRefactoredLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does not
|
||||
have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
@@ -65,8 +66,8 @@ class TestRefactoredLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -91,7 +92,8 @@ class TestRefactoredLinuxCNCPost(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
# header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing.
|
||||
# Only test length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 14)
|
||||
@@ -151,8 +153,6 @@ M2
|
||||
expected = "G0 X10.00 Y20.00 Z30.00"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
@@ -210,7 +210,7 @@ M2
|
||||
expected = "G0 X0.3937 Y0.7874 Z1.1811"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
args = ("--no-header --inches --precision=2 --no-show-editor")
|
||||
args = "--no-header --inches --precision=2 --no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
result = gcode.splitlines()[5]
|
||||
expected = "G0 X0.39 Y0.79 Z1.18"
|
||||
|
||||
@@ -39,10 +39,10 @@ class TestRefactoredMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -53,10 +53,11 @@ class TestRefactoredMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does not
|
||||
have access to the class `self` reference. This method is able to
|
||||
call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
|
||||
@@ -64,8 +65,8 @@ class TestRefactoredMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
# Setup and tear down methods called before and after each unit test
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -90,7 +91,8 @@ class TestRefactoredMach3Mach4Post(PathTestUtils.PathTestBase):
|
||||
postables = [self.docobj]
|
||||
|
||||
# Test generating with header
|
||||
# header contains a time stamp that messes up unit testing. Only test length of result
|
||||
# Header contains a time stamp that messes up unit testing.
|
||||
# Only test length of result.
|
||||
args = "--no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
self.assertTrue(len(gcode.splitlines()) == 14)
|
||||
@@ -150,8 +152,6 @@ M2
|
||||
expected = "G0 X10.00 Y20.00 Z30.00"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
|
||||
|
||||
def test020(self):
|
||||
"""
|
||||
Test Line Numbers
|
||||
@@ -209,7 +209,7 @@ M2
|
||||
expected = "G0 X0.3937 Y0.7874 Z1.1811"
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
args = ("--no-header --inches --precision=2 --no-show-editor")
|
||||
args = "--no-header --inches --precision=2 --no-show-editor"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
result = gcode.splitlines()[5]
|
||||
expected = "G0 X0.39 Y0.79 Z1.18"
|
||||
|
||||
@@ -41,10 +41,10 @@ class TestRefactoredTestPost(PathTestUtils.PathTestBase):
|
||||
def setUpClass(cls):
|
||||
"""setUpClass()...
|
||||
|
||||
This method is called upon instantiation of this test class. Add code and objects here
|
||||
that are needed for the duration of the test() methods in this class. In other words,
|
||||
set up the 'global' test environment here; use the `setUp()` method to set up a 'local'
|
||||
test environment.
|
||||
This method is called upon instantiation of this test class. Add code
|
||||
and objects here that are needed for the duration of the test() methods
|
||||
in this class. In other words, set up the 'global' test environment
|
||||
here; use the `setUp()` method to set up a 'local' test environment.
|
||||
This method does not have access to the class `self` reference, but it
|
||||
is able to call static methods within this same class.
|
||||
"""
|
||||
@@ -55,10 +55,11 @@ class TestRefactoredTestPost(PathTestUtils.PathTestBase):
|
||||
def tearDownClass(cls):
|
||||
"""tearDownClass()...
|
||||
|
||||
This method is called prior to destruction of this test class. Add code and objects here
|
||||
that cleanup the test environment after the test() methods in this class have been executed.
|
||||
This method does not have access to the class `self` reference. This method
|
||||
is able to call static methods within this same class.
|
||||
This method is called prior to destruction of this test class. Add
|
||||
code and objects here that cleanup the test environment after the
|
||||
test() methods in this class have been executed. This method does
|
||||
not have access to the class `self` reference. This method is able
|
||||
to call static methods within this same class.
|
||||
"""
|
||||
# Close geometry document without saving
|
||||
FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
|
||||
@@ -68,8 +69,8 @@ class TestRefactoredTestPost(PathTestUtils.PathTestBase):
|
||||
def setUp(self):
|
||||
"""setUp()...
|
||||
|
||||
This method is called prior to each `test()` method. Add code and objects here
|
||||
that are needed for multiple `test()` methods.
|
||||
This method is called prior to each `test()` method. Add code and
|
||||
objects here that are needed for multiple `test()` methods.
|
||||
"""
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
self.con = FreeCAD.Console
|
||||
@@ -103,7 +104,8 @@ class TestRefactoredTestPost(PathTestUtils.PathTestBase):
|
||||
# print("--------\n" + gcode + "--------\n")
|
||||
self.assertEqual(gcode.splitlines()[0], "(Exported by FreeCAD)")
|
||||
self.assertEqual(
|
||||
gcode.splitlines()[1], "(Post Processor: PathScripts.post.refactored_test_post)"
|
||||
gcode.splitlines()[1],
|
||||
"(Post Processor: PathScripts.post.refactored_test_post)",
|
||||
)
|
||||
self.assertEqual(gcode.splitlines()[2], "(Cam File: )")
|
||||
self.assertIn("(Output Time: ", gcode.splitlines()[3])
|
||||
@@ -134,7 +136,8 @@ G21
|
||||
# print("--------\n" + gcode + "--------\n")
|
||||
self.assertEqual(gcode.splitlines()[0], "(Exported by FreeCAD)")
|
||||
self.assertEqual(
|
||||
gcode.splitlines()[1], "(Post Processor: PathScripts.post.refactored_test_post)"
|
||||
gcode.splitlines()[1],
|
||||
"(Post Processor: PathScripts.post.refactored_test_post)",
|
||||
)
|
||||
self.assertEqual(gcode.splitlines()[2], "(Cam File: )")
|
||||
self.assertIn("(Output Time: ", gcode.splitlines()[3])
|
||||
@@ -237,13 +240,15 @@ G21
|
||||
args = ""
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
# print("--------\n" + gcode + "--------\n")
|
||||
# Note: The "internal" F speed is in mm/s, while the output F speed is in mm/min.
|
||||
# Note: The "internal" F speed is in mm/s,
|
||||
# while the output F speed is in mm/min.
|
||||
self.assertEqual(gcode.splitlines()[2], "G1 X10.000 Y20.000 Z30.000 F7387.407")
|
||||
|
||||
args = "--feed-precision=2"
|
||||
gcode = postprocessor.export(postables, "gcode.tmp", args)
|
||||
# print("--------\n" + gcode + "--------\n")
|
||||
# Note: The "internal" F speed is in mm/s, while the output F speed is in mm/min.
|
||||
# Note: The "internal" F speed is in mm/s,
|
||||
# while the output F speed is in mm/min.
|
||||
self.assertEqual(gcode.splitlines()[2], "G1 X10.000 Y20.000 Z30.000 F7387.41")
|
||||
|
||||
def test00150(self):
|
||||
|
||||
Reference in New Issue
Block a user