Merge branch 'master' into fixes/post

This commit is contained in:
Daniel Wood
2020-03-03 21:24:00 +00:00
committed by GitHub
213 changed files with 18429 additions and 25118 deletions

View File

@@ -162,6 +162,7 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
# Perform and cancel canned drilling cycle
self.commandlist.append(Path.Command(cmd, params))
self.commandlist.append(Path.Command('G80'))
self.commandlist.append(Path.Command('G0', {'Z': obj.SafeHeight.Value}))

View File

@@ -3,6 +3,7 @@
# * *
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * (c) Gauthier Briere - 2018, 2019 *
# * (c) Schildkroet - 2019-2020 *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -108,7 +109,7 @@ TOOLTIP_ARGS = parser.format_help()
# ***************************************************************************
MOTION_COMMANDS = ['G0', 'G00', 'G1', 'G01', 'G2', 'G02', 'G3', 'G03'] # Motion gCode commands definition
RAPID_MOVES = ['G0', 'G00'] # Rapid moves gCode commands definition
SUPPRESS_COMMANDS = ['G98', 'G80'] # These commands are ignored by commenting them out
SUPPRESS_COMMANDS = [] # These commands are ignored by commenting them out
COMMAND_SPACE = " "
# Global variables storing current position
CURRENT_X = 0
@@ -208,6 +209,7 @@ def export(objectslist, filename, argstring):
global UNIT_FORMAT
global UNIT_SPEED_FORMAT
global MOTION_MODE
global SUPPRESS_COMMANDS
print("Post Processor: " + __name__ + " postprocessing...")
gcode = ""
@@ -217,6 +219,13 @@ def export(objectslist, filename, argstring):
gcode += linenumber() + "(Exported by FreeCAD)\n"
gcode += linenumber() + "(Post Processor: " + __name__ + ")\n"
gcode += linenumber() + "(Output Time:" + str(datetime.datetime.now()) + ")\n"
# Check canned cycles for drilling
if TRANSLATE_DRILL_CYCLES:
if len(SUPPRESS_COMMANDS) == 0:
SUPPRESS_COMMANDS = ['G98', 'G80']
else:
SUPPRESS_COMMANDS += ['G98', 'G80']
# Write the preamble
if OUTPUT_COMMENTS:
@@ -249,6 +258,17 @@ def export(objectslist, filename, argstring):
if not hasattr(obj, "Path"):
print("The object " + obj.Name + " is not a path. Please select only path and Compounds.")
return
isActive = True
if hasattr(obj, "Active") or hasattr(obj, 'Base') and hasattr(obj.Base, "Active"):
if hasattr(obj, "Active"):
isActive = obj.Active
else:
isActive = obj.Base.Active
if isActive:
print("obj.Base.active true")
else:
print("obj.active false")
# do the pre_op
if OUTPUT_BCNC:
@@ -259,6 +279,23 @@ def export(objectslist, filename, argstring):
gcode += linenumber() + "(Begin operation: " + obj.Label + ")\n"
for line in PRE_OPERATION.splitlines(True):
gcode += linenumber() + line
# get coolant mode
coolantMode = 'None'
if hasattr(obj, "CoolantMode") or hasattr(obj, 'Base') and hasattr(obj.Base, "CoolantMode"):
if hasattr(obj, "CoolantMode"):
coolantMode = obj.CoolantMode
else:
coolantMode = obj.Base.CoolantMode
# turn coolant on if required
if OUTPUT_COMMENTS and isActive:
if not coolantMode == 'None':
gcode += linenumber() + '(Coolant On:' + coolantMode + ')\n'
if coolantMode == 'Flood' and isActive:
gcode += linenumber() + 'M8' + '\n'
if coolantMode == 'Mist' and isActive:
gcode += linenumber() + 'M7' + '\n'
# Parse the op
gcode += parse(obj)
@@ -269,6 +306,13 @@ def export(objectslist, filename, argstring):
for line in POST_OPERATION.splitlines(True):
gcode += linenumber() + line
# turn coolant off if required
if not coolantMode == 'None':
if OUTPUT_COMMENTS and isActive:
gcode += linenumber() + '(Coolant Off:' + coolantMode + ')\n'
if isActive:
gcode += linenumber() +'M9' + '\n'
# do the post_amble
if OUTPUT_BCNC:
gcode += linenumber() + "(Block-name: post_amble)\n"
@@ -380,7 +424,7 @@ def parse(pathobj):
# store the latest command
lastcommand = command
# Memorise la position courante pour calcul des mouvements relatis et du plan de retrait
# Memorizes the current position for calculating the related movements and the withdrawal plan
if command in MOTION_COMMANDS:
if 'X' in c.Parameters:
CURRENT_X = Units.Quantity(c.Parameters['X'], FreeCAD.Units.Length)
@@ -398,7 +442,7 @@ def parse(pathobj):
if TRANSLATE_DRILL_CYCLES:
if command in ('G81', 'G82', 'G83'):
out += drill_translate(outstring, command, c.Parameters)
# Efface la ligne que l'on vient de translater
# Erase the line we just translated
del(outstring[:])
outstring = []

View File

@@ -185,6 +185,14 @@ def export(objectslist, filename, argstring):
for obj in objectslist:
# Skip inactive operations
if hasattr(obj, 'Active'):
if not obj.Active:
continue
if hasattr(obj, 'Base') and hasattr(obj.Base, 'Active'):
if not obj.Base.Active:
continue
# fetch machine details
job = PathUtils.findParentJob(obj)
@@ -210,16 +218,22 @@ def export(objectslist, filename, argstring):
for line in PRE_OPERATION.splitlines(True):
gcode += linenumber() + line
# get coolant mode
coolantMode = 'None'
if hasattr(obj, "CoolantMode") or hasattr(obj, 'Base') and hasattr(obj.Base, "CoolantMode"):
if hasattr(obj, "CoolantMode"):
coolantMode = obj.CoolantMode
else:
coolantMode = obj.Base.CoolantMode
# turn coolant on if required
if hasattr(obj, "CoolantMode"):
coolantMode = obj.CoolantMode
if OUTPUT_COMMENTS:
if not coolantMode == 'None':
gcode += linenumber() + '(Coolant On:' + coolantMode + ')\n'
if coolantMode == 'Flood':
gcode += linenumber() + 'M8' + '\n'
if coolantMode == 'Mist':
gcode += linenumber() + 'M7' + '\n'
if OUTPUT_COMMENTS:
if not coolantMode == 'None':
gcode += linenumber() + '(Coolant On:' + coolantMode + ')\n'
if coolantMode == 'Flood':
gcode += linenumber() + 'M8' + '\n'
if coolantMode == 'Mist':
gcode += linenumber() + 'M7' + '\n'
# process the operation gcode
gcode += parse(obj)
@@ -231,12 +245,10 @@ def export(objectslist, filename, argstring):
gcode += linenumber() + line
# turn coolant off if required
if hasattr(obj, "CoolantMode"):
coolantMode = obj.CoolantMode
if not coolantMode == 'None':
if OUTPUT_COMMENTS:
gcode += linenumber() + '(Coolant Off:' + coolantMode + ')\n'
gcode += linenumber() +'M9' + '\n'
if not coolantMode == 'None':
if OUTPUT_COMMENTS:
gcode += linenumber() + '(Coolant Off:' + coolantMode + ')\n'
gcode += linenumber() +'M9' + '\n'
# do the post_amble
if OUTPUT_COMMENTS:
@@ -354,8 +366,8 @@ def parse(pathobj):
# Check for Tool Change:
if command == 'M6':
# if OUTPUT_COMMENTS:
# out += linenumber() + "(begin toolchange)\n"
# stop the spindle
out += linenumber() + "M5\n"
for line in TOOL_CHANGE.splitlines(True):
out += linenumber() + line