- few bugs solved regarding the newly created empty objects

This commit is contained in:
Marius Stanciu
2019-12-06 23:00:43 +02:00
committed by Marius
parent d683402884
commit 2ca509ca04
35 changed files with 283 additions and 250 deletions

225
preprocessors/Berta_CNC.py Normal file
View File

@@ -0,0 +1,225 @@
##############################################################
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Matthieu Berthomé #
# Date: 5/26/2017 #
# #
# Correction & Adaptation for Berta CNC machine #
# Date: 24/10/2019 #
# #
# MIT Licence #
##############################################################
from FlatCAMPostProc import *
class Berta_CNC(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' + '\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\n'
gcode += '(Spindle Speed: %s RPM)\n' % str(p['spindlespeed'])
gcode += '(Berta)\n'
gcode += 'G90 G94 G17 G91.1'
gcode += (
# This line allow you to sets the machine to METRIC / INCH in the GUI
'G20\n' if p.units.upper() == 'IN' else 'G21\n')
# gcode += 'G21\n' # This line sets the machine to METRIC ONLY
# gcode += 'G20\n' # This line sets the machine to INCH ONLY
gcode += 'G64 P0.03\n'
gcode += 'M110\n'
gcode += 'G54\n'
gcode += 'G0\n'
gcode += '(Berta)\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):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
else:
x_toolchange = 0
y_toolchange = 0
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC})
M0""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC})
M0""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
gcode += '(Berta)\n'
gcode += 'M111\n'
gcode += 'M30\n'
gcode += '(Berta)\n'
return gcode
def feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
def z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self, p):
return 'M05'

157
preprocessors/ISEL_CNC.py Normal file
View File

@@ -0,0 +1,157 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Matthieu Berthomé #
# Date: 5/26/2017 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
class ISEL_CNC(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' + '\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\n'
gcode += '(Spindle Speed: %s RPM)\n' % str(p['spindlespeed'])
gcode += 'G71\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):
f_plunge = p.f_plunge
no_drills = 1
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
gcode = """
M05
T{tool}
M06
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M01""".format(tool=int(p.tool), t_drills=no_drills, toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
gcode = """
M05
T{tool}
M06
(MSG, Change to Tool Dia = {toolC})
M01""".format(tool=int(p.tool), toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
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 z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M05'

162
preprocessors/Paste_1.py Normal file
View File

@@ -0,0 +1,162 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
class Paste_1(FlatCAMPostProc_Tools):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = [float(eval(a)) for a in p['xy_toolchange'].split(",") if a != '']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
gcode += '(TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + ')\n'
gcode += '(Feedrate_XY: ' + str(p['frxy']) + units + '/min' + ')\n'
gcode += '(Feedrate_Z: ' + str(p['frz']) + units + '/min' + ')\n'
gcode += '(Feedrate_Z_Dispense: ' + str(p['frz_dispense']) + units + '/min' + ')\n'
gcode += '(Z_Dispense_Start: ' + str(p['z_start']) + units + ')\n'
gcode += '(Z_Dispense: ' + str(p['z_dispense']) + units + ')\n'
gcode += '(Z_Dispense_Stop: ' + str(p['z_stop']) + units + ')\n'
gcode += '(Z_Travel: ' + str(p['z_travel']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
if 'Paste' in p.pp_solderpaste_name:
gcode += '(Preprocessor SolderPaste Dispensing Geometry: ' + str(p.pp_solderpaste_name) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\n'
gcode += '(Spindle Speed FWD: %s RPM)\n' % str(p['speedfwd'])
gcode += '(Spindle Speed REV: %s RPM)\n' % str(p['speedrev'])
gcode += '(Dwell FWD: %s RPM)\n' % str(p['dwellfwd'])
gcode += '(Dwell REV: %s RPM)\n' % str(p['dwellrev'])
gcode += ('G20\n' if p.units.upper() == 'IN' else 'G21\n')
gcode += 'G90\n'
gcode += 'G94\n'
return gcode
def lift_code(self, p):
return 'G00 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_travel']))
def down_z_start_code(self, p):
return 'G01 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_start']))
def lift_z_dispense_code(self, p):
return 'G01 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_dispense']))
def down_z_stop_code(self, p):
return 'G01 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_stop']))
def toolchange_code(self, p):
z_toolchange = float(p['z_toolchange'])
toolchangexy = [float(eval(a)) for a in p['xy_toolchange'].split(",") if a != '']
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
else:
x_toolchange = 0.0
y_toolchange = 0.0
toolC_formatted = '%.*f' % (p.decimals, float(p['toolC']))
if toolchangexy is not None:
gcode = """
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
(MSG, Change to Tool with Nozzle Dia = {toolC})
M0
G00 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(int(p.tool)),
toolC=toolC_formatted)
else:
gcode = """
G00 Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool with Nozzle Dia = {toolC})
M0
G00 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(int(p.tool)),
toolC=toolC_formatted)
return gcode
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) + '\nG00 Z' + \
self.coordinate_format%(p.coords_decimals, float(p['z_travel']))
def linear_code(self, p):
return ('G01 ' + self.position_code(p)).format(**p)
def end_code(self, p):
coords_xy = [float(eval(a)) for a in p['xy_toolchange'].split(",") if a != '']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, float(p['z_toolchange'])) + "\n")
if coords_xy is not None:
gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
return gcode
def feedrate_xy_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, float(p['frxy'])))
def z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, float(p['frz'])))
def feedrate_z_dispense_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, float(p['frz_dispense'])))
def spindle_fwd_code(self, p):
if p.spindlespeed:
return 'M03 S' + str(float(p['speedfwd']))
else:
return 'M03'
def spindle_rev_code(self, p):
if p.spindlespeed:
return 'M04 S' + str(float(p['speedrev']))
else:
return 'M04'
def spindle_off_code(self,p):
return 'M05'
def dwell_fwd_code(self, p):
if p.dwelltime:
return 'G4 P' + str(float(p['dwellfwd']))
def dwell_rev_code(self, p):
if p.dwelltime:
return 'G4 P' + str(float(p['dwellrev']))

211
preprocessors/Repetier.py Normal file
View File

@@ -0,0 +1,211 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
class Repetier(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
feedrate_rapid_format = feedrate_format
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + '\n'
gcode += ';Z_Move: ' + str(p['z_move']) + units + '\n'
gcode += ';Z Toolchange: ' + str(p['z_toolchange']) + units + '\n'
if coords_xy is not None:
gcode += ';X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + '\n'
else:
gcode += ';X,Y Toolchange: ' + "None" + units + '\n'
gcode += ';Z Start: ' + str(p['startz']) + units + '\n'
gcode += ';Z End: ' + str(p['z_end']) + 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 += ';Preprocessor Excellon: ' + str(p['pp_excellon_name']) + '\n'
else:
gcode += ';Preprocessor Geometry: ' + str(p['pp_geometry_name']) + '\n' + '\n'
gcode += ';X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + '\n'
gcode += ';Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + '\n\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.inline_z_feedrate_code(p)
def toolchange_code(self, p):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
G0 Z{z_toolchange}
G0 X{x_toolchange} Y{y_toolchange}
M84
@pause Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
G0 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
else:
gcode = """
G0 Z{z_toolchange}
M84
@pause Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
G0 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG0 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
G0 Z{z_toolchange}
G0 X{x_toolchange} Y{y_toolchange}
M84
@pause Change to tool T{tool} with Tool Dia = {toolC}
G0 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
else:
gcode = """
G0 Z{z_toolchange}
M84
@pause Change to tool T{tool} with Tool Dia = {toolC}
G0 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG0 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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.inline_feedrate_code(p)
def end_code(self, p):
coords_xy = p['xy_toolchange']
gcode = ('G0 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n")
if coords_xy is not None:
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 inline_feedrate_code(self, p):
return 'F' + self.feedrate_format %(p.fr_decimals, p.feedrate)
def inline_z_feedrate_code(self, p):
return 'F' + self.feedrate_format %(p.fr_decimals, p.z_feedrate)
def z_feedrate_code(self, p):
return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
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 'M106 S%d' % p.spindlespeed
else:
return 'M106'
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M107'

View File

@@ -0,0 +1,127 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
# for Roland Preprocessors it is mandatory for the preprocessor 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.z_end / 25.4
else:
z = p.z_end
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 z_feedrate_code(self, p):
fr_sec = p.z_feedrate / 60
# valid feedrate for MDX20 is between 0.1mm/sec and 15mm/sec (6mm/min to 900mm/min)
if p.z_feedrate >= 900:
fr_sec = 15
if p.z_feedrate < 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'

View File

@@ -0,0 +1,169 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
class Toolchange_Custom(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\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 += 'G17\n'
gcode += 'G94\n'
return gcode
def startz_code(self, p):
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):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
M6
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
M6
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
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 z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M05'

View File

@@ -0,0 +1,272 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
class Toolchange_Probe_MACH3(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + units + '/min' + ')\n'
gcode += '(Feedrate rapids ' + str(p['feedrate_rapid']) + units + '/min' + ')\n' + '\n'
gcode += '(Feedrate Probe ' + str(p['feedrate_probe']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + units + ')\n'
gcode += '(Z Probe Depth: ' + str(p['z_pdepth']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\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 += 'G17\n'
gcode += 'G94\n'
gcode += '(MSG, WARNING: Make sure you do zero on all axis. ' \
'For Z axis, since it will be probed, make a rough estimate and do a zero.)\n'
gcode += 'M0'
return gcode
def startz_code(self, p):
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):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
M5
T{tool}
M6
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE ||| Drills for this tool = {t_drills})
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
M0
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
else:
gcode = """
M5
T{tool}
M6
G00 Z{z_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE ||| Drills for this tool = {t_drills})
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
M0
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
# if f_plunge is True:
# gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
M5
T{tool}
M6
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE)
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
M0
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
tool=int(p.tool),
toolC=toolC_formatted)
else:
gcode = """
M5
T{tool}
M6
G00 Z{z_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| CONNECT THE PROBE)
M0
F{feedrate_probe}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_in_between}
F{feedrate_probe_slow}
G31 Z{z_pdepth}
G92 Z0
G00 Z{z_move}
(MSG, Remove any clips or other devices used for probing. CNC work is resuming ...)
M0
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
tool=int(p.tool),
toolC=toolC_formatted)
# if f_plunge is True:
# gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
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 z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M05'

View File

@@ -0,0 +1,230 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
class Toolchange_manual(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' + '\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\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 += 'G17\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):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
G00 X{x_toolchange} Y{y_toolchange}
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0
G01 Z0
(MSG, Adjust the tool T{tool} to touch the material and then tighten it slightly.)
M0
G00 Z{z_toolchange}
(MSG, Now the tool can be tightened more securely.)
M0
""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format%(p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0
G01 Z0
(MSG, Adjust the tool T{tool} to touch the material and then tighten it slightly.)
M0
G00 Z{z_toolchange}
(MSG, Now the tool can be tightened more securely.)
M0
""".format(
z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
G00 X{x_toolchange}Y{y_toolchange}
(MSG, Change to Tool Dia = {toolC})
M0
G01 Z0
(MSG, Adjust the tool T{tool} to touch the material and then tighten it slightly.)
M0
G00 Z{z_toolchange}
(MSG, Now the tool can be tightened more securely.)
M0
""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format%(p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
(MSG, Change to Tool Dia = {toolC})
M0
G01 Z0
(MSG, Adjust the tool T{tool} to touch the material and then tighten it slightly.)
M0
G00 Z{z_toolchange}
(MSG, Now the tool can be tightened more securely.)
M0
""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
else:
gcode += 'G00 X0 Y0' + "\n"
return gcode
def feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
def z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M05'

View File

213
preprocessors/default.py Normal file
View File

@@ -0,0 +1,213 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Matthieu Berthomé #
# Date: 5/26/2017 #
# MIT Licence #
# ########################################################## ##
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['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' + '\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\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):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
G00 X{x_toolchange} Y{y_toolchange}
M6
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0
G00 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0
G00 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC})
M0
G00 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC})
M0
G00 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
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 z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M05'

212
preprocessors/grbl_11.py Normal file
View File

@@ -0,0 +1,212 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Matthieu Berthomé #
# Date: 5/26/2017 #
# MIT Licence #
# ########################################################## ##
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['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\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):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0
G00 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0
G00 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
M5
G00 Z{z_toolchange}
G00 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC})
M0
G00 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
else:
gcode = """
M5
G00 Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC})
M0
G00 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG00 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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) + \
' F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
def end_code(self, p):
coords_xy = p['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
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 z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M05'

103
preprocessors/grbl_laser.py Normal file
View File

@@ -0,0 +1,103 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Matthieu Berthomé #
# Date: 5/26/2017 #
# MIT Licence #
# ########################################################## ##
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 = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n'
gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n" + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\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 S0'
def down_code(self, p):
if p.spindlespeed:
return 'M03 S%d' % p.spindlespeed
else:
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) + \
' F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
def end_code(self, p):
coords_xy = p['xy_toolchange']
gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
if coords_xy is not None:
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 z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
return ''
def spindle_stop_code(self,p):
return 'M05'

84
preprocessors/hpgl.py Normal file
View File

@@ -0,0 +1,84 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
# for Roland Preprocessors it is mandatory for the preprocessor 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 hpgl(FlatCAMPostProc):
coordinate_format = "%.*f"
def start_code(self, p):
gcode = 'IN;'
return gcode
def startz_code(self, p):
return ''
def lift_code(self, p):
gcode = 'PU;' + '\n'
return gcode
def down_code(self, p):
gcode = 'PD;' + '\n'
return gcode
def toolchange_code(self, p):
return 'SP%d;' % int(p.tool)
def up_to_zero_code(self, p):
return ''
def position_code(self, p):
units = str(p['units']).lower()
# we work only with METRIC units because HPGL mention only metric units so if FlatCAM units are INCH we
# transform them in METRIC
if units == 'in':
x = p.x * 25.4
y = p.y * 25.4
else:
x = p.x
y = p.y
# we need to have the coordinates as multiples of 0.025mm
x = round(x / 0.025) * 25 / 1000
y = round(y / 0.025) * 25 / 1000
return ('PA' + self.coordinate_format + ',' + self.coordinate_format + ';') % \
(p.coords_decimals, x, p.coords_decimals, y)
def rapid_code(self, p):
return self.position_code(p).format(**p)
def linear_code(self, p):
return self.position_code(p).format(**p)
def end_code(self, p):
gcode = self.position_code(p).format(**p)
return gcode
def feedrate_code(self, p):
return ''
def z_feedrate_code(self, p):
return ''
def feedrate_rapid_code(self, p):
return ''
def spindle_code(self, p):
return ''
def dwell_code(self, p):
return ''
def spindle_stop_code(self,p):
return ''

205
preprocessors/line_xyz.py Normal file
View File

@@ -0,0 +1,205 @@
# ########################################################## ##
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ########################################################## ##
from FlatCAMPostProc import *
class line_xyz(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.*f'
def start_code(self, p):
units = ' ' + str(p['units']).lower()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + ')\n'
gcode += '(Z_Move: ' + str(p['z_move']) + units + ')\n'
gcode += '(Z Toolchange: ' + str(p['z_toolchange']) + units + ')\n'
if coords_xy is not None:
gcode += '(X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + ')\n'
else:
gcode += '(X,Y Toolchange: ' + "None" + units + ')\n'
gcode += '(Z Start: ' + str(p['startz']) + units + ')\n'
gcode += '(Z End: ' + str(p['z_end']) + 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 += '(Preprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
else:
gcode += '(Preprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n'
gcode += '(X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + ')\n'
gcode += '(Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + ')\n\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:
g = 'G00 ' + 'X' + self.coordinate_format%(p.coords_decimals, p.x) + \
' Y' + self.coordinate_format%(p.coords_decimals, p.y) + \
' Z' + self.coordinate_format%(p.coords_decimals, p.startz)
return g
else:
return ''
def lift_code(self, p):
g = 'G00 ' + 'X' + self.coordinate_format % (p.coords_decimals, p.x) + \
' Y' + self.coordinate_format % (p.coords_decimals, p.y) + \
' Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
return g
def down_code(self, p):
g = 'G01 ' + 'X' + self.coordinate_format % (p.coords_decimals, p.x) + \
' Y' + self.coordinate_format % (p.coords_decimals, p.y) + \
' Z' + self.coordinate_format % (p.coords_decimals, p.z_cut)
return g
def toolchange_code(self, p):
z_toolchange = p.z_toolchange
xy_toolchange = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if xy_toolchange is not None:
x_toolchange = xy_toolchange[0]
y_toolchange = xy_toolchange[1]
else:
if str(p['options']['type']) == 'Excellon':
x_toolchange = p.oldx
y_toolchange = p.oldy
else:
x_toolchange = p.x
y_toolchange = p.y
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
gcode = """
M5
G00 X{x_toolchange} Y{x_toolchange} Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
M0""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += """\nG00 X{x_toolchange} Y{x_toolchange} Z{z_move}""".format(
x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_move=self.coordinate_format % (p.coords_decimals, p.z_move))
return gcode
else:
gcode = """
M5
G00 X{x_toolchange} Y{x_toolchange} Z{z_toolchange}
T{tool}
M6
(MSG, Change to Tool Dia = {toolC})
M0""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += """\nG00 X{x_toolchange} Y{x_toolchange} Z{z_move}""".format(
x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_move=self.coordinate_format % (p.coords_decimals, p.z_move))
return gcode
def up_to_zero_code(self, p):
g = 'G01 ' + 'X' + self.coordinate_format % (p.coords_decimals, p.x) + \
' Y' + self.coordinate_format % (p.coords_decimals, p.y) + \
' Z0'
return g
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):
g = ('G00 ' + self.position_code(p)).format(**p)
g += ' Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
return g
def linear_code(self, p):
g = ('G01 ' + self.position_code(p)).format(**p)
g += ' Z' + self.coordinate_format % (p.coords_decimals, p.z_cut)
return g
def end_code(self, p):
coords_xy = p['xy_toolchange']
if coords_xy is not None:
g = 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
else:
g = ('G00 ' + self.position_code(p)).format(**p)
g += ' Z' + self.coordinate_format % (p.coords_decimals, p.z_end)
return g
def feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
def z_feedrate_code(self, p):
return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def spindle_code(self, p):
sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M05'

222
preprocessors/marlin.py Normal file
View File

@@ -0,0 +1,222 @@
# ##########################################################
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# File Author: Marius Adrian Stanciu (c) #
# Date: 3/10/2019 #
# MIT Licence #
# ##########################################################
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()
coords_xy = p['xy_toolchange']
gcode = ''
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
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['z_feedrate']) + 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['z_depthpercut']) + units + ' <=>' + \
str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + '\n'
gcode += ';Z_Move: ' + str(p['z_move']) + units + '\n'
gcode += ';Z Toolchange: ' + str(p['z_toolchange']) + units + '\n'
if coords_xy is not None:
gcode += ';X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
p.decimals, coords_xy[1]) + units + '\n'
else:
gcode += ';X,Y Toolchange: ' + "None" + units + '\n'
gcode += ';Z Start: ' + str(p['startz']) + units + '\n'
gcode += ';Z End: ' + str(p['z_end']) + 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 += ';Preprocessor Excellon: ' + str(p['pp_excellon_name']) + '\n'
else:
gcode += ';Preprocessor Geometry: ' + str(p['pp_geometry_name']) + '\n' + '\n'
gcode += ';X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + '\n'
gcode += ';Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + '\n\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.inline_z_feedrate_code(p)
def toolchange_code(self, p):
z_toolchange = p.z_toolchange
toolchangexy = p.xy_toolchange
f_plunge = p.f_plunge
gcode = ''
if toolchangexy is not None:
x_toolchange = toolchangexy[0]
y_toolchange = toolchangexy[1]
no_drills = 1
if int(p.tool) == 1 and p.startz is not None:
z_toolchange = p.startz
toolC_formatted = '%.*f' % (p.decimals, p.toolC)
if str(p['options']['type']) == 'Excellon':
for i in p['options']['Tools_in_use']:
if i[0] == p.tool:
no_drills = i[2]
if toolchangexy is not None:
gcode = """
M5
G0 Z{z_toolchange}
G0 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
;MSG, Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
M0
G0 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
else:
gcode = """
M5
G0 Z{z_toolchange}
T{tool}
M6
;MSG, Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
M0
G0 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
t_drills=no_drills,
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG0 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
else:
if toolchangexy is not None:
gcode = """
M5
G0 Z{z_toolchange}
G0 X{x_toolchange} Y{y_toolchange}
T{tool}
M6
;MSG, Change to Tool Dia = {toolC}
M0
G0 Z{z_toolchange}
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
else:
gcode = """
M5
G0 Z{z_toolchange}
T{tool}
M6
;MSG, Change to Tool Dia = {toolC}
M0
G0 Z{z_toolchange}
""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
tool=int(p.tool),
toolC=toolC_formatted)
if f_plunge is True:
gcode += '\nG0 Z%.*f' % (p.coords_decimals, p.z_move)
return gcode
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.inline_feedrate_code(p)
def end_code(self, p):
coords_xy = p['xy_toolchange']
gcode = ('G0 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n")
if coords_xy is not None:
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 inline_feedrate_code(self, p):
return 'F' + self.feedrate_format %(p.fr_decimals, p.feedrate)
def inline_z_feedrate_code(self, p):
return 'F' + self.feedrate_format %(p.fr_decimals, p.z_feedrate)
def z_feedrate_code(self, p):
return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
def feedrate_rapid_code(self, p):
return 'F' + self.feedrate_rapid_format % (p.fr_decimals, p.feedrate_rapid)
def spindle_code(self, p):
sdir = {'CW': 'M3', 'CCW': 'M4'}[p.spindledir]
if p.spindlespeed:
return '%s S%s' % (sdir, str(p.spindlespeed))
else:
return sdir
def dwell_code(self, p):
if p.dwelltime:
return 'G4 P' + str(p.dwelltime)
def spindle_stop_code(self,p):
return 'M5'