-clean-up before merge
This commit is contained in:
119
postprocessors/Roland_MDX_20.py
Normal file
119
postprocessors/Roland_MDX_20.py
Normal file
@@ -0,0 +1,119 @@
|
||||
from FlatCAMPostProc import *
|
||||
|
||||
|
||||
# for Roland Postprocessors it is mandatory for the postprocessor name (python file and class name, both of them must be
|
||||
# the same) to contain the following keyword, case-sensitive: 'Roland' without the quotes.
|
||||
class Roland_MDX_20(FlatCAMPostProc):
|
||||
|
||||
coordinate_format = "%.1f"
|
||||
feedrate_format = '%.1f'
|
||||
feedrate_rapid_format = '%.1f'
|
||||
|
||||
def start_code(self, p):
|
||||
gcode = ';;^IN;' + '\n'
|
||||
gcode += '^PA;'
|
||||
return gcode
|
||||
|
||||
def startz_code(self, p):
|
||||
return ''
|
||||
|
||||
def lift_code(self, p):
|
||||
if p.units.upper() == 'IN':
|
||||
z = p.z_move / 25.4
|
||||
else:
|
||||
z = p.z_move
|
||||
gcode = self.feedrate_rapid_code(p) + '\n'
|
||||
gcode += self.position_code(p).format(**p) + ',' + str(float(z * 40.0)) + ';'
|
||||
return gcode
|
||||
|
||||
def down_code(self, p):
|
||||
if p.units.upper() == 'IN':
|
||||
z = p.z_cut / 25.4
|
||||
else:
|
||||
z = p.z_cut
|
||||
gcode = self.feedrate_code(p) + '\n'
|
||||
gcode += self.position_code(p).format(**p) + ',' + str(float(z * 40.0)) + ';'
|
||||
return gcode
|
||||
|
||||
def toolchange_code(self, p):
|
||||
return ''
|
||||
|
||||
def up_to_zero_code(self, p):
|
||||
gcode = self.feedrate_code(p) + '\n'
|
||||
gcode += self.position_code(p).format(**p) + ',' + '0' + ';'
|
||||
return gcode
|
||||
|
||||
def position_code(self, p):
|
||||
if p.units.upper() == 'IN':
|
||||
x = p.x / 25.4
|
||||
y = p.y / 25.4
|
||||
else:
|
||||
x = p.x
|
||||
y = p.y
|
||||
return ('Z' + self.coordinate_format + ',' + self.coordinate_format) % (float(x * 40.0), float(y * 40.0))
|
||||
|
||||
def rapid_code(self, p):
|
||||
if p.units.upper() == 'IN':
|
||||
z = p.z_move / 25.4
|
||||
else:
|
||||
z = p.z_move
|
||||
gcode = self.feedrate_rapid_code(p) + '\n'
|
||||
gcode += self.position_code(p).format(**p) + ',' + str(float(z * 40.0)) + ';'
|
||||
return gcode
|
||||
|
||||
def linear_code(self, p):
|
||||
if p.units.upper() == 'IN':
|
||||
z = p.z / 25.4
|
||||
else:
|
||||
z = p.z
|
||||
gcode = self.feedrate_code(p) + '\n'
|
||||
gcode += self.position_code(p).format(**p) + ',' + str(float(z * 40.0)) + ';'
|
||||
return gcode
|
||||
|
||||
def end_code(self, p):
|
||||
if p.units.upper() == 'IN':
|
||||
z = p.endz / 25.4
|
||||
else:
|
||||
z = p.endz
|
||||
gcode = self.feedrate_rapid_code(p) + '\n'
|
||||
gcode += self.position_code(p).format(**p) + ',' + str(float(z * 40.0)) + ';'
|
||||
return gcode
|
||||
|
||||
def feedrate_code(self, p):
|
||||
fr_sec = p.feedrate / 60
|
||||
|
||||
# valid feedrate for MDX20 is between 0.1mm/sec and 15mm/sec (6mm/min to 900mm/min)
|
||||
if p.feedrate >= 900:
|
||||
fr_sec = 15
|
||||
if p.feedrate < 6:
|
||||
fr_sec = 6
|
||||
return 'V' + str(self.feedrate_format % fr_sec) + ';'
|
||||
|
||||
def feedrate_z_code(self, p):
|
||||
fr_sec = p.feedrate_z / 60
|
||||
|
||||
# valid feedrate for MDX20 is between 0.1mm/sec and 15mm/sec (6mm/min to 900mm/min)
|
||||
if p.feedrate_z >= 900:
|
||||
fr_sec = 15
|
||||
if p.feedrate_z < 6:
|
||||
fr_sec = 6
|
||||
return 'V' + str(self.feedrate_format % fr_sec) + ';'
|
||||
|
||||
def feedrate_rapid_code(self, p):
|
||||
fr_sec = p.feedrate_rapid / 60
|
||||
|
||||
# valid feedrate for MDX20 is between 0.1mm/sec and 15mm/sec (6mm/min to 900mm/min)
|
||||
if p.feedrate_rapid >= 900:
|
||||
fr_sec = 15
|
||||
if p.feedrate_rapid < 6:
|
||||
fr_sec = 6
|
||||
return 'V' + str(self.feedrate_format % fr_sec) + ';'
|
||||
|
||||
def spindle_code(self, p):
|
||||
return '!MC1'
|
||||
|
||||
def dwell_code(self, p):
|
||||
return''
|
||||
|
||||
def spindle_stop_code(self,p):
|
||||
return '!MC0'
|
||||
0
postprocessors/__init__.py
Normal file
0
postprocessors/__init__.py
Normal file
137
postprocessors/default.py
Normal file
137
postprocessors/default.py
Normal file
@@ -0,0 +1,137 @@
|
||||
from FlatCAMPostProc import *
|
||||
|
||||
|
||||
class default(FlatCAMPostProc):
|
||||
|
||||
coordinate_format = "%.*f"
|
||||
feedrate_format = '%.*f'
|
||||
|
||||
def start_code(self, p):
|
||||
units = ' ' + str(p['units']).lower()
|
||||
coords_xy = p['toolchange_xy']
|
||||
gcode = ''
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += '(TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + ')\n'
|
||||
|
||||
gcode += '(Feedrate: ' + str(p['feedrate']) + units + '/min' + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += '(Feedrate_Z: ' + str(p['feedrate_z']) + units + '/min' + ')\n'
|
||||
|
||||
gcode += '(Feedrate rapids ' + str(p['feedrate_rapid']) + units + '/min' + ')\n' + '\n'
|
||||
gcode += '(Z_Cut: ' + str(p['z_cut']) + units + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
if p['multidepth'] is True:
|
||||
gcode += '(DepthPerCut: ' + str(p['depthpercut']) + units + ' <=>' + \
|
||||
str(math.ceil(abs(p['z_cut']) / p['depthpercut'])) + ' passes' + ')\n'
|
||||
|
||||
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
|
||||
gcode += '(Z Toolchange: ' + str(p['toolchangez']) + units + ')\n'
|
||||
gcode += '(X,Y Toolchange: ' + "%.4f, %.4f" % (coords_xy[0], coords_xy[1]) + units + ')\n'
|
||||
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
|
||||
gcode += '(Z End: ' + str(p['endz']) + units + ')\n'
|
||||
gcode += '(Steps per circle: ' + str(p['steps_per_circle']) + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
||||
gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
|
||||
else:
|
||||
gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n'
|
||||
|
||||
gcode += '(Spindle Speed: %s RPM)\n' % str(p['spindlespeed'])
|
||||
|
||||
gcode += ('G20\n' if p.units.upper() == 'IN' else 'G21\n')
|
||||
gcode += 'G90\n'
|
||||
gcode += 'G94\n'
|
||||
|
||||
return gcode
|
||||
|
||||
def startz_code(self, p):
|
||||
if p.startz is not None:
|
||||
return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.startz)
|
||||
else:
|
||||
return ''
|
||||
|
||||
def lift_code(self, p):
|
||||
return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.z_move)
|
||||
|
||||
def down_code(self, p):
|
||||
return 'G01 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut)
|
||||
|
||||
def toolchange_code(self, p):
|
||||
toolchangez = p.toolchangez
|
||||
toolchangexy = p.toolchange_xy
|
||||
toolchangex = toolchangexy[0]
|
||||
toolchangey = toolchangexy[1]
|
||||
|
||||
no_drills = 1
|
||||
|
||||
if int(p.tool) == 1 and p.startz is not None:
|
||||
toolchangez = p.startz
|
||||
|
||||
if p.units.upper() == 'MM':
|
||||
toolC_formatted = format(p.toolC, '.2f')
|
||||
else:
|
||||
toolC_formatted = format(p.toolC, '.4f')
|
||||
|
||||
if str(p['options']['type']) == 'Excellon':
|
||||
for i in p['options']['Tools_in_use']:
|
||||
if i[0] == p.tool:
|
||||
no_drills = i[2]
|
||||
return """G00 Z{toolchangez}
|
||||
T{tool}
|
||||
M5
|
||||
M6
|
||||
(MSG, Change to Tool Dia = {toolC}, Total drills for current tool = {t_drills})
|
||||
M0""".format(toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
t_drills=no_drills,
|
||||
toolC=toolC_formatted)
|
||||
else:
|
||||
return """G00 Z{toolchangez}
|
||||
T{tool}
|
||||
M5
|
||||
M6
|
||||
(MSG, Change to Tool Dia = {toolC})
|
||||
M0""".format(toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
toolC=toolC_formatted)
|
||||
|
||||
def up_to_zero_code(self, p):
|
||||
return 'G01 Z0'
|
||||
|
||||
def position_code(self, p):
|
||||
return ('X' + self.coordinate_format + ' Y' + self.coordinate_format) % \
|
||||
(p.coords_decimals, p.x, p.coords_decimals, p.y)
|
||||
|
||||
def rapid_code(self, p):
|
||||
return ('G00 ' + self.position_code(p)).format(**p)
|
||||
|
||||
def linear_code(self, p):
|
||||
return ('G01 ' + self.position_code(p)).format(**p)
|
||||
|
||||
def end_code(self, p):
|
||||
coords_xy = p['toolchange_xy']
|
||||
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.endz) + "\n")
|
||||
gcode += 'G00 X{x}Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
|
||||
return gcode
|
||||
|
||||
def feedrate_code(self, p):
|
||||
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
|
||||
|
||||
def feedrate_z_code(self, p):
|
||||
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate_z))
|
||||
|
||||
def spindle_code(self, p):
|
||||
if p.spindlespeed:
|
||||
return 'M03 S' + str(p.spindlespeed)
|
||||
else:
|
||||
return 'M03'
|
||||
|
||||
def dwell_code(self, p):
|
||||
if p.dwelltime:
|
||||
return 'G4 P' + str(p.dwelltime)
|
||||
|
||||
def spindle_stop_code(self,p):
|
||||
return 'M05'
|
||||
134
postprocessors/grbl_11.py
Normal file
134
postprocessors/grbl_11.py
Normal file
@@ -0,0 +1,134 @@
|
||||
from FlatCAMPostProc import *
|
||||
|
||||
|
||||
class grbl_11(FlatCAMPostProc):
|
||||
|
||||
coordinate_format = "%.*f"
|
||||
feedrate_format = '%.*f'
|
||||
|
||||
def start_code(self, p):
|
||||
units = ' ' + str(p['units']).lower()
|
||||
coords_xy = p['toolchange_xy']
|
||||
gcode = ''
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += '(TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + ')\n' + '\n'
|
||||
|
||||
gcode += '(Feedrate: ' + str(p['feedrate']) + units + '/min' + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += '(Feedrate_Z: ' + str(p['feedrate_z']) + units + '/min' + ')\n'
|
||||
|
||||
gcode += '(Feedrate rapids ' + str(p['feedrate_rapid']) + units + '/min' + ')\n' + '\n'
|
||||
gcode += '(Z_Cut: ' + str(p['z_cut']) + units + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
if p['multidepth'] is True:
|
||||
gcode += '(DepthPerCut: ' + str(p['depthpercut']) + units + ' <=>' + \
|
||||
str(math.ceil(abs(p['z_cut']) / p['depthpercut'])) + ' passes' + ')\n'
|
||||
|
||||
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
|
||||
gcode += '(Z Toolchange: ' + str(p['toolchangez']) + units + ')\n'
|
||||
gcode += '(X,Y Toolchange: ' + "%.4f, %.4f" % (coords_xy[0], coords_xy[1]) + units + ')\n'
|
||||
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
|
||||
gcode += '(Z End: ' + str(p['endz']) + units + ')\n'
|
||||
gcode += '(Steps per circle: ' + str(p['steps_per_circle']) + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
||||
gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
|
||||
else:
|
||||
gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n'
|
||||
|
||||
gcode += '(Spindle Speed: ' + str(p['spindlespeed']) + ' RPM' + ')\n' + '\n'
|
||||
|
||||
gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n"
|
||||
gcode += 'G90\n'
|
||||
gcode += 'G94\n'
|
||||
gcode += 'G17\n'
|
||||
|
||||
return gcode
|
||||
|
||||
def startz_code(self, p):
|
||||
if p.startz is not None:
|
||||
return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.startz)
|
||||
else:
|
||||
return ''
|
||||
|
||||
def lift_code(self, p):
|
||||
return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.z_move)
|
||||
|
||||
def down_code(self, p):
|
||||
return 'G01 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut)
|
||||
|
||||
def toolchange_code(self, p):
|
||||
toolchangez = p.toolchangez
|
||||
|
||||
if int(p.tool) == 1 and p.startz is not None:
|
||||
toolchangez = p.startz
|
||||
|
||||
if p.units.upper() == 'MM':
|
||||
toolC_formatted = format(p.toolC, '.2f')
|
||||
else:
|
||||
toolC_formatted = format(p.toolC, '.4f')
|
||||
|
||||
for i in p['options']['Tools_in_use']:
|
||||
if i[0] == p.tool:
|
||||
no_drills = i[2]
|
||||
|
||||
if str(p['options']['type']) == 'Excellon':
|
||||
return """G00 Z{toolchangez}
|
||||
T{tool}
|
||||
M5
|
||||
M6
|
||||
(MSG, Change to Tool Dia = {toolC}, Total drills for current tool = {t_drills})
|
||||
M0""".format(toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
t_drills=no_drills,
|
||||
toolC=toolC_formatted)
|
||||
else:
|
||||
return """G00 Z{toolchangez}
|
||||
T{tool}
|
||||
M5
|
||||
M6
|
||||
(MSG, Change to Tool Dia = {toolC})
|
||||
M0""".format(toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
toolC=toolC_formatted)
|
||||
|
||||
def up_to_zero_code(self, p):
|
||||
return 'G01 Z0'
|
||||
|
||||
def position_code(self, p):
|
||||
return ('X' + self.coordinate_format + ' Y' + self.coordinate_format) % \
|
||||
(p.coords_decimals, p.x, p.coords_decimals, p.y)
|
||||
|
||||
def rapid_code(self, p):
|
||||
return ('G00 ' + self.position_code(p)).format(**p)
|
||||
|
||||
def linear_code(self, p):
|
||||
return ('G01 ' + self.position_code(p)).format(**p) + " " + self.feedrate_code(p)
|
||||
|
||||
def end_code(self, p):
|
||||
coords_xy = p['toolchange_xy']
|
||||
gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.endz) + "\n")
|
||||
gcode += 'G00 X{x}Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
|
||||
return gcode
|
||||
|
||||
def feedrate_code(self, p):
|
||||
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
|
||||
|
||||
def feedrate_z_code(self, p):
|
||||
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate_z))
|
||||
|
||||
def spindle_code(self,p):
|
||||
if p.spindlespeed:
|
||||
return 'M03 S%d' % p.spindlespeed
|
||||
else:
|
||||
return 'M03'
|
||||
|
||||
def dwell_code(self, p):
|
||||
if p.dwelltime:
|
||||
return 'G4 P' + str(p.dwelltime)
|
||||
|
||||
def spindle_stop_code(self,p):
|
||||
return 'M05'
|
||||
74
postprocessors/grbl_laser.py
Normal file
74
postprocessors/grbl_laser.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from FlatCAMPostProc import *
|
||||
|
||||
# This post processor is configured to output code that
|
||||
# is compatible with almost any version of Grbl.
|
||||
|
||||
|
||||
class grbl_laser(FlatCAMPostProc):
|
||||
|
||||
coordinate_format = "%.*f"
|
||||
feedrate_format = '%.*f'
|
||||
|
||||
def start_code(self, p):
|
||||
units = ' ' + str(p['units']).lower()
|
||||
gcode = ''
|
||||
|
||||
gcode += '(Feedrate: ' + str(p['feedrate']) + units + '/min' + ')\n'
|
||||
gcode += '(Feedrate rapids ' + str(p['feedrate_rapid']) + units + '/min' + ')\n' + '\n'
|
||||
|
||||
gcode += '(Steps per circle: ' + str(p['steps_per_circle']) + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
||||
gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
|
||||
else:
|
||||
gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n'
|
||||
|
||||
gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n"
|
||||
gcode += 'G90\n'
|
||||
gcode += 'G94\n'
|
||||
gcode += 'G17\n'
|
||||
|
||||
return gcode
|
||||
|
||||
def startz_code(self, p):
|
||||
return ''
|
||||
|
||||
def lift_code(self, p):
|
||||
return 'M05'
|
||||
|
||||
def down_code(self, p):
|
||||
return 'M03'
|
||||
|
||||
def toolchange_code(self, p):
|
||||
return ''
|
||||
|
||||
def up_to_zero_code(self, p):
|
||||
return 'M05'
|
||||
|
||||
def position_code(self, p):
|
||||
return ('X' + self.coordinate_format + ' Y' + self.coordinate_format) % \
|
||||
(p.coords_decimals, p.x, p.coords_decimals, p.y)
|
||||
|
||||
def rapid_code(self, p):
|
||||
return ('G00 ' + self.position_code(p)).format(**p)
|
||||
|
||||
def linear_code(self, p):
|
||||
return ('G01 ' + self.position_code(p)).format(**p) + " " + self.feedrate_code(p)
|
||||
|
||||
def end_code(self, p):
|
||||
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.endz) + "\n")
|
||||
gcode += 'G00 X0Y0'
|
||||
return gcode
|
||||
|
||||
def feedrate_code(self, p):
|
||||
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
|
||||
|
||||
def spindle_code(self,p):
|
||||
if p.spindlespeed:
|
||||
return 'S%d' % p.spindlespeed
|
||||
|
||||
def dwell_code(self, p):
|
||||
return ''
|
||||
|
||||
def spindle_stop_code(self,p):
|
||||
return 'M05'
|
||||
152
postprocessors/manual_toolchange.py
Normal file
152
postprocessors/manual_toolchange.py
Normal file
@@ -0,0 +1,152 @@
|
||||
from FlatCAMPostProc import *
|
||||
|
||||
|
||||
class manual_toolchange(FlatCAMPostProc):
|
||||
|
||||
coordinate_format = "%.*f"
|
||||
feedrate_format = '%.*f'
|
||||
|
||||
def start_code(self, p):
|
||||
units = ' ' + str(p['units']).lower()
|
||||
coords_xy = p['toolchange_xy']
|
||||
gcode = ''
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += '(TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + ')\n'
|
||||
|
||||
gcode += '(Feedrate: ' + str(p['feedrate']) + units + '/min' + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += '(Feedrate_Z: ' + str(p['feedrate_z']) + units + '/min' + ')\n'
|
||||
|
||||
gcode += '(Feedrate rapids ' + str(p['feedrate_rapid']) + units + '/min' + ')\n' + '\n'
|
||||
gcode += '(Z_Cut: ' + str(p['z_cut']) + units + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
if p['multidepth'] is True:
|
||||
gcode += '(DepthPerCut: ' + str(p['depthpercut']) + units + ' <=>' + \
|
||||
str(math.ceil(abs(p['z_cut']) / p['depthpercut'])) + ' passes' + ')\n'
|
||||
|
||||
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
|
||||
gcode += '(Z Toolchange: ' + str(p['toolchangez']) + units + ')\n'
|
||||
gcode += '(X,Y Toolchange: ' + "%.4f, %.4f" % (coords_xy[0], coords_xy[1]) + units + ')\n'
|
||||
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
|
||||
gcode += '(Z End: ' + str(p['endz']) + units + ')\n'
|
||||
gcode += '(Steps per circle: ' + str(p['steps_per_circle']) + ')\n'
|
||||
|
||||
if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
||||
gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
|
||||
else:
|
||||
gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n'
|
||||
|
||||
gcode += '(Spindle Speed: %s RPM)\n' % str(p['spindlespeed'])
|
||||
|
||||
gcode += ('G20\n' if p.units.upper() == 'IN' else 'G21\n')
|
||||
gcode += 'G90\n'
|
||||
gcode += 'G94\n'
|
||||
|
||||
return gcode
|
||||
|
||||
def startz_code(self, p):
|
||||
if p.startz is not None:
|
||||
return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.startz)
|
||||
else:
|
||||
return ''
|
||||
|
||||
def lift_code(self, p):
|
||||
return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
|
||||
|
||||
def down_code(self, p):
|
||||
return 'G01 Z' + self.coordinate_format % (p.coords_decimals, p.z_cut)
|
||||
|
||||
def toolchange_code(self, p):
|
||||
toolchangez = p.toolchangez
|
||||
toolchangexy = p.toolchange_xy
|
||||
toolchangex = toolchangexy[0]
|
||||
toolchangey = toolchangexy[1]
|
||||
|
||||
no_drills = 1
|
||||
|
||||
if int(p.tool) == 1 and p.startz is not None:
|
||||
toolchangez = p.startz
|
||||
|
||||
if p.units.upper() == 'MM':
|
||||
toolC_formatted = format(p.toolC, '.2f')
|
||||
else:
|
||||
toolC_formatted = format(p.toolC, '.4f')
|
||||
|
||||
for i in p['options']['Tools_in_use']:
|
||||
if i[0] == p.tool:
|
||||
no_drills = i[2]
|
||||
|
||||
if str(p['options']['type']) == 'Excellon':
|
||||
return """G00 Z{toolchangez}
|
||||
T{tool}
|
||||
M5
|
||||
G00 X{toolchangex}Y{toolchangey}
|
||||
(MSG, Change to Tool Dia = {toolC}, Total drills for current tool = {t_drills})
|
||||
M0
|
||||
G01 Z0
|
||||
M0
|
||||
G00 Z{toolchangez}
|
||||
M0
|
||||
""".format(toolchangex=self.coordinate_format%(p.coords_decimals, toolchangex),
|
||||
toolchangey=self.coordinate_format%(p.coords_decimals, toolchangey),
|
||||
toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
t_drills=no_drills,
|
||||
toolC=toolC_formatted)
|
||||
else:
|
||||
return """G00 Z{toolchangez}
|
||||
T{tool}
|
||||
M5
|
||||
G00 X{toolchangex}Y{toolchangey}
|
||||
(MSG, Change to Tool Dia = {toolC})
|
||||
M0
|
||||
G01 Z0
|
||||
M0
|
||||
G00 Z{toolchangez}
|
||||
M0
|
||||
""".format(toolchangex=self.coordinate_format%(p.coords_decimals, toolchangex),
|
||||
toolchangey=self.coordinate_format%(p.coords_decimals, toolchangey),
|
||||
toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
toolC=toolC_formatted)
|
||||
|
||||
def up_to_zero_code(self, p):
|
||||
return 'G01 Z0'
|
||||
|
||||
def position_code(self, p):
|
||||
return ('X' + self.coordinate_format + ' Y' + self.coordinate_format) % \
|
||||
(p.coords_decimals, p.x, p.coords_decimals, p.y)
|
||||
|
||||
def rapid_code(self, p):
|
||||
return ('G00 ' + self.position_code(p)).format(**p)
|
||||
|
||||
def linear_code(self, p):
|
||||
return ('G01 ' + self.position_code(p)).format(**p)
|
||||
|
||||
def end_code(self, p):
|
||||
coords_xy = p['toolchange_xy']
|
||||
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.endz) + "\n")
|
||||
gcode += 'G00 X{x}Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
|
||||
return gcode
|
||||
|
||||
def feedrate_code(self, p):
|
||||
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
|
||||
|
||||
def feedrate_z_code(self, p):
|
||||
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate_z))
|
||||
|
||||
def spindle_code(self,p):
|
||||
if p.spindlespeed:
|
||||
return 'M03 S' + str(p.spindlespeed)
|
||||
else:
|
||||
return 'M03'
|
||||
|
||||
def dwell_code(self, p):
|
||||
if p.dwelltime:
|
||||
return 'G4 P' + str(p.dwelltime)
|
||||
|
||||
def spindle_stop_code(self,p):
|
||||
return 'M05'
|
||||
135
postprocessors/marlin.py
Normal file
135
postprocessors/marlin.py
Normal file
@@ -0,0 +1,135 @@
|
||||
from FlatCAMPostProc import *
|
||||
|
||||
|
||||
class marlin(FlatCAMPostProc):
|
||||
|
||||
coordinate_format = "%.*f"
|
||||
feedrate_format = '%.*f'
|
||||
feedrate_rapid_format = feedrate_format
|
||||
|
||||
def start_code(self, p):
|
||||
units = ' ' + str(p['units']).lower()
|
||||
gcode = ''
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += ';TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + '\n' + '\n'
|
||||
|
||||
gcode += ';Feedrate: ' + str(p['feedrate']) + units + '/min' + '\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
gcode += ';Feedrate_Z: ' + str(p['feedrate_z']) + units + '/min' + '\n'
|
||||
|
||||
gcode += ';Feedrate rapids ' + str(p['feedrate_rapid']) + units + '/min' + '\n' + '\n'
|
||||
gcode += ';Z_Cut: ' + str(p['z_cut']) + units + '\n'
|
||||
|
||||
if str(p['options']['type']) == 'Geometry':
|
||||
if p['multidepth'] is True:
|
||||
gcode += ';DepthPerCut: ' + str(p['depthpercut']) + units + ' <=>' + \
|
||||
str(math.ceil(abs(p['z_cut']) / p['depthpercut'])) + ' passes' + '\n'
|
||||
|
||||
gcode += ';Z_Move: ' + str(p['z_move']) + units + '\n'
|
||||
gcode += ';Z Toolchange: ' + str(p['toolchangez']) + units + '\n'
|
||||
gcode += ';Z Start: ' + str(p['startz']) + units + '\n'
|
||||
gcode += ';Z End: ' + str(p['endz']) + units + '\n'
|
||||
gcode += ';Steps per circle: ' + str(p['steps_per_circle']) + '\n'
|
||||
|
||||
if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
||||
gcode += ';Postprocessor Excellon: ' + str(p['pp_excellon_name']) + '\n'
|
||||
else:
|
||||
gcode += ';Postprocessor Geometry: ' + str(p['pp_geometry_name']) + '\n'
|
||||
|
||||
gcode += ';Spindle Speed: ' + str(p['spindlespeed']) + ' RPM' + '\n' + '\n'
|
||||
|
||||
gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n"
|
||||
gcode += 'G90\n'
|
||||
|
||||
return gcode
|
||||
|
||||
def startz_code(self, p):
|
||||
if p.startz is not None:
|
||||
return 'G0 Z' + self.coordinate_format % (p.coords_decimals, p.startz)
|
||||
else:
|
||||
return ''
|
||||
|
||||
def lift_code(self, p):
|
||||
return 'G0 Z' + self.coordinate_format%(p.coords_decimals, p.z_move) + " " + self.feedrate_rapid_code(p)
|
||||
|
||||
def down_code(self, p):
|
||||
return 'G1 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut) + " " + self.end_feedrate_code(p)
|
||||
|
||||
def toolchange_code(self, p):
|
||||
toolchangez = p.toolchangez
|
||||
no_drills = 1
|
||||
|
||||
if int(p.tool) == 1 and p.startz is not None:
|
||||
toolchangez = p.startz
|
||||
|
||||
if p.units.upper() == 'MM':
|
||||
toolC_formatted = format(p.toolC, '.2f')
|
||||
else:
|
||||
toolC_formatted = format(p.toolC, '.4f')
|
||||
|
||||
for i in p['options']['Tools_in_use']:
|
||||
if i[0] == p.tool:
|
||||
no_drills = i[2]
|
||||
|
||||
if str(p['options']['type']) == 'Excellon':
|
||||
return """G0 Z{toolchangez}
|
||||
M5
|
||||
M0 Change to Tool Dia = {toolC}, Total drills for current tool = {t_drills}
|
||||
""".format(toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
t_drills=no_drills,
|
||||
toolC=toolC_formatted)
|
||||
else:
|
||||
return """G0 Z{toolchangez}
|
||||
M5
|
||||
M0 Change to Tool Dia = {toolC}
|
||||
""".format(toolchangez=self.coordinate_format%(p.coords_decimals, toolchangez),
|
||||
tool=int(p.tool),
|
||||
toolC=toolC_formatted)
|
||||
|
||||
def up_to_zero_code(self, p):
|
||||
return 'G1 Z0' + " " + self.feedrate_code(p)
|
||||
|
||||
def position_code(self, p):
|
||||
return ('X' + self.coordinate_format + ' Y' + self.coordinate_format) % \
|
||||
(p.coords_decimals, p.x, p.coords_decimals, p.y)
|
||||
|
||||
def rapid_code(self, p):
|
||||
return ('G0 ' + self.position_code(p)).format(**p) + " " + self.feedrate_rapid_code(p)
|
||||
|
||||
def linear_code(self, p):
|
||||
return ('G1 ' + self.position_code(p)).format(**p) + " " + self.end_feedrate_code(p)
|
||||
|
||||
def end_code(self, p):
|
||||
coords_xy = p['toolchange_xy']
|
||||
gcode = ('G0 Z' + self.feedrate_format %(p.fr_decimals, p.endz) + " " + self.feedrate_rapid_code(p) + "\n")
|
||||
gcode += 'G0 X{x}Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + " " + self.feedrate_rapid_code(p) + "\n"
|
||||
|
||||
return gcode
|
||||
|
||||
def feedrate_code(self, p):
|
||||
return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
|
||||
|
||||
def end_feedrate_code(self, p):
|
||||
return 'F' + self.feedrate_format %(p.fr_decimals, p.feedrate)
|
||||
|
||||
def feedrate_z_code(self, p):
|
||||
return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate_z))
|
||||
|
||||
def feedrate_rapid_code(self, p):
|
||||
return 'F' + self.feedrate_rapid_format % (p.fr_decimals, p.feedrate_rapid)
|
||||
|
||||
def spindle_code(self,p):
|
||||
if p.spindlespeed:
|
||||
return 'M3 S%d' % p.spindlespeed
|
||||
else:
|
||||
return 'M3'
|
||||
|
||||
def dwell_code(self, p):
|
||||
if p.dwelltime:
|
||||
return 'G4 P' + str(p.dwelltime)
|
||||
|
||||
def spindle_stop_code(self,p):
|
||||
return 'M5'
|
||||
Reference in New Issue
Block a user