From b1136c0c263937849ab4d31be80950b0c8338ebe Mon Sep 17 00:00:00 2001 From: "Sebastian @ HfG" Date: Thu, 27 Mar 2025 17:14:14 +0100 Subject: [PATCH] init --- carvera_edge_cut.py | 170 ++++++++++++++++++++++++++++++++++++++ carvera_edge_cut_0.8mm.py | 170 ++++++++++++++++++++++++++++++++++++++ carvera_free_pads.py | 170 ++++++++++++++++++++++++++++++++++++++ carvera_hole_mill.py | 170 ++++++++++++++++++++++++++++++++++++++ carvera_iso.py | 170 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 850 insertions(+) create mode 100644 carvera_edge_cut.py create mode 100644 carvera_edge_cut_0.8mm.py create mode 100644 carvera_free_pads.py create mode 100644 carvera_hole_mill.py create mode 100644 carvera_iso.py diff --git a/carvera_edge_cut.py b/carvera_edge_cut.py new file mode 100644 index 0000000..84607e0 --- /dev/null +++ b/carvera_edge_cut.py @@ -0,0 +1,170 @@ +# ########################################################## +# FlatCAM: 2D Post-processing for Manufacturing # +# http://flatcam.org # +# File Author: Matthieu Berthomé # +# Date: 5/26/2017 # +# MIT Licence # +# ########################################################## + +from appPreProcessor import * + + +class carvera_EDGE(PreProc): + + include_header = True + coordinate_format = "%.*f" + feedrate_format = '%.*f' + + def start_code(self, p): + units = ' ' + str(p['units']).lower() + coords_xy = p['xy_toolchange'] + end_coords_xy = p['xy_end'] + gcode = '(This preprocessor is a test for the Carvera from Makera.)\n' + gcode += '(It is made to work with the Carvera)\n\n' + + 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_XY: ' + str(p['feedrate']) + units + '/min' + ')\n' + 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 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' + + elif str(p['options']['type']) == 'Excellon' and p['use_ui'] is True: + gcode += '\n(TOOLS DIAMETER: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Dia: %s' % str(val["tooldia"]) + ')\n' + + gcode += '\n(FEEDRATE Z: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate: %s' % \ + str(val['data']["tools_drill_feedrate_z"]) + ')\n' + + gcode += '\n(FEEDRATE RAPIDS: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate Rapids: %s' % \ + str(val['data']["tools_drill_feedrate_rapid"]) + ')\n' + + gcode += '\n(Z_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Cut: %s' % str(val['data']["tools_drill_cutz"]) + ')\n' + + gcode += '\n(Tools Offset: )\n' + for tool, val in p['exc_cnc_tools'].items(): + gcode += '(Tool: %s -> ' % str(val['tool']) + 'Offset Z: %s' % \ + str(val['data']["tools_drill_offset"]) + ')\n' + + if p['multidepth'] is True: + gcode += '\n(DEPTH_PER_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'DeptPerCut: %s' % \ + str(val['data']["tools_drill_depthperpass"]) + ')\n' + + gcode += '\n(Z_MOVE: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Move: %s' % str(val['data']["tools_drill_travelz"]) + ')\n' + gcode += '\n' + + if p['toolchange'] is True: + 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' + if end_coords_xy is not None: + gcode += '(X,Y End: ' + "%.*f, %.*f" % (p.decimals, end_coords_xy[0], + p.decimals, end_coords_xy[1]) + units + ')\n' + else: + gcode += '(X,Y End: ' + "None" + 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 ' if p.units.upper() == 'IN' else 'G21 ') + gcode += 'G40 ' + gcode += 'G54\n' + gcode += 'G80 ' + gcode += 'G90 ' + 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): + return "T4 M06" + + 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): + end_coords_xy = p['xy_end'] + gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n") + + if end_coords_xy and end_coords_xy != '': + gcode += 'G00 X{x} Y{y}'.format(x=end_coords_xy[0], y=end_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' + + def test_function(self, p): + return '(HALLO)' \ No newline at end of file diff --git a/carvera_edge_cut_0.8mm.py b/carvera_edge_cut_0.8mm.py new file mode 100644 index 0000000..d468d27 --- /dev/null +++ b/carvera_edge_cut_0.8mm.py @@ -0,0 +1,170 @@ +# ########################################################## +# FlatCAM: 2D Post-processing for Manufacturing # +# http://flatcam.org # +# File Author: Matthieu Berthomé # +# Date: 5/26/2017 # +# MIT Licence # +# ########################################################## + +from appPreProcessor import * + + +class carvera_EDGE(PreProc): + + include_header = True + coordinate_format = "%.*f" + feedrate_format = '%.*f' + + def start_code(self, p): + units = ' ' + str(p['units']).lower() + coords_xy = p['xy_toolchange'] + end_coords_xy = p['xy_end'] + gcode = '(This preprocessor is a test for the Carvera from Makera.)\n' + gcode += '(It is made to work with the Carvera)\n\n' + + 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_XY: ' + str(p['feedrate']) + units + '/min' + ')\n' + 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 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' + + elif str(p['options']['type']) == 'Excellon' and p['use_ui'] is True: + gcode += '\n(TOOLS DIAMETER: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Dia: %s' % str(val["tooldia"]) + ')\n' + + gcode += '\n(FEEDRATE Z: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate: %s' % \ + str(val['data']["tools_drill_feedrate_z"]) + ')\n' + + gcode += '\n(FEEDRATE RAPIDS: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate Rapids: %s' % \ + str(val['data']["tools_drill_feedrate_rapid"]) + ')\n' + + gcode += '\n(Z_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Cut: %s' % str(val['data']["tools_drill_cutz"]) + ')\n' + + gcode += '\n(Tools Offset: )\n' + for tool, val in p['exc_cnc_tools'].items(): + gcode += '(Tool: %s -> ' % str(val['tool']) + 'Offset Z: %s' % \ + str(val['data']["tools_drill_offset"]) + ')\n' + + if p['multidepth'] is True: + gcode += '\n(DEPTH_PER_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'DeptPerCut: %s' % \ + str(val['data']["tools_drill_depthperpass"]) + ')\n' + + gcode += '\n(Z_MOVE: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Move: %s' % str(val['data']["tools_drill_travelz"]) + ')\n' + gcode += '\n' + + if p['toolchange'] is True: + 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' + if end_coords_xy is not None: + gcode += '(X,Y End: ' + "%.*f, %.*f" % (p.decimals, end_coords_xy[0], + p.decimals, end_coords_xy[1]) + units + ')\n' + else: + gcode += '(X,Y End: ' + "None" + 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 ' if p.units.upper() == 'IN' else 'G21 ') + gcode += 'G40 ' + gcode += 'G54\n' + gcode += 'G80 ' + gcode += 'G90 ' + 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): + return "T3 M06" + + 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): + end_coords_xy = p['xy_end'] + gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n") + + if end_coords_xy and end_coords_xy != '': + gcode += 'G00 X{x} Y{y}'.format(x=end_coords_xy[0], y=end_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' + + def test_function(self, p): + return '(HALLO)' \ No newline at end of file diff --git a/carvera_free_pads.py b/carvera_free_pads.py new file mode 100644 index 0000000..9587d1c --- /dev/null +++ b/carvera_free_pads.py @@ -0,0 +1,170 @@ +# ########################################################## +# FlatCAM: 2D Post-processing for Manufacturing # +# http://flatcam.org # +# File Author: Matthieu Berthomé # +# Date: 5/26/2017 # +# MIT Licence # +# ########################################################## + +from appPreProcessor import * + + +class carvera_PADS(PreProc): + + include_header = True + coordinate_format = "%.*f" + feedrate_format = '%.*f' + + def start_code(self, p): + units = ' ' + str(p['units']).lower() + coords_xy = p['xy_toolchange'] + end_coords_xy = p['xy_end'] + gcode = '(This preprocessor is a test for the Carvera from Makera.)\n' + gcode += '(It is made to work with the Carvera)\n\n' + + 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_XY: ' + str(p['feedrate']) + units + '/min' + ')\n' + 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 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' + + elif str(p['options']['type']) == 'Excellon' and p['use_ui'] is True: + gcode += '\n(TOOLS DIAMETER: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Dia: %s' % str(val["tooldia"]) + ')\n' + + gcode += '\n(FEEDRATE Z: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate: %s' % \ + str(val['data']["tools_drill_feedrate_z"]) + ')\n' + + gcode += '\n(FEEDRATE RAPIDS: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate Rapids: %s' % \ + str(val['data']["tools_drill_feedrate_rapid"]) + ')\n' + + gcode += '\n(Z_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Cut: %s' % str(val['data']["tools_drill_cutz"]) + ')\n' + + gcode += '\n(Tools Offset: )\n' + for tool, val in p['exc_cnc_tools'].items(): + gcode += '(Tool: %s -> ' % str(val['tool']) + 'Offset Z: %s' % \ + str(val['data']["tools_drill_offset"]) + ')\n' + + if p['multidepth'] is True: + gcode += '\n(DEPTH_PER_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'DeptPerCut: %s' % \ + str(val['data']["tools_drill_depthperpass"]) + ')\n' + + gcode += '\n(Z_MOVE: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Move: %s' % str(val['data']["tools_drill_travelz"]) + ')\n' + gcode += '\n' + + if p['toolchange'] is True: + 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' + if end_coords_xy is not None: + gcode += '(X,Y End: ' + "%.*f, %.*f" % (p.decimals, end_coords_xy[0], + p.decimals, end_coords_xy[1]) + units + ')\n' + else: + gcode += '(X,Y End: ' + "None" + 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 ' if p.units.upper() == 'IN' else 'G21 ') + gcode += 'G40 ' + gcode += 'G54\n' + gcode += 'G80 ' + gcode += 'G90 ' + 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): + return "T5 M06" + + 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): + end_coords_xy = p['xy_end'] + gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n") + + if end_coords_xy and end_coords_xy != '': + gcode += 'G00 X{x} Y{y}'.format(x=end_coords_xy[0], y=end_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' + + def test_function(self, p): + return '(HALLO)' \ No newline at end of file diff --git a/carvera_hole_mill.py b/carvera_hole_mill.py new file mode 100644 index 0000000..1674d60 --- /dev/null +++ b/carvera_hole_mill.py @@ -0,0 +1,170 @@ +# ########################################################## +# FlatCAM: 2D Post-processing for Manufacturing # +# http://flatcam.org # +# File Author: Matthieu Berthomé # +# Date: 5/26/2017 # +# MIT Licence # +# ########################################################## + +from appPreProcessor import * + + +class carvera_HOLE(PreProc): + + include_header = True + coordinate_format = "%.*f" + feedrate_format = '%.*f' + + def start_code(self, p): + units = ' ' + str(p['units']).lower() + coords_xy = p['xy_toolchange'] + end_coords_xy = p['xy_end'] + gcode = '(This preprocessor is a test for the Carvera from Makera.)\n' + gcode += '(It is made to work with the Carvera)\n\n' + + 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_XY: ' + str(p['feedrate']) + units + '/min' + ')\n' + 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 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' + + elif str(p['options']['type']) == 'Excellon' and p['use_ui'] is True: + gcode += '\n(TOOLS DIAMETER: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Dia: %s' % str(val["tooldia"]) + ')\n' + + gcode += '\n(FEEDRATE Z: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate: %s' % \ + str(val['data']["tools_drill_feedrate_z"]) + ')\n' + + gcode += '\n(FEEDRATE RAPIDS: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate Rapids: %s' % \ + str(val['data']["tools_drill_feedrate_rapid"]) + ')\n' + + gcode += '\n(Z_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Cut: %s' % str(val['data']["tools_drill_cutz"]) + ')\n' + + gcode += '\n(Tools Offset: )\n' + for tool, val in p['exc_cnc_tools'].items(): + gcode += '(Tool: %s -> ' % str(val['tool']) + 'Offset Z: %s' % \ + str(val['data']["tools_drill_offset"]) + ')\n' + + if p['multidepth'] is True: + gcode += '\n(DEPTH_PER_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'DeptPerCut: %s' % \ + str(val['data']["tools_drill_depthperpass"]) + ')\n' + + gcode += '\n(Z_MOVE: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Move: %s' % str(val['data']["tools_drill_travelz"]) + ')\n' + gcode += '\n' + + if p['toolchange'] is True: + 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' + if end_coords_xy is not None: + gcode += '(X,Y End: ' + "%.*f, %.*f" % (p.decimals, end_coords_xy[0], + p.decimals, end_coords_xy[1]) + units + ')\n' + else: + gcode += '(X,Y End: ' + "None" + 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 ' if p.units.upper() == 'IN' else 'G21 ') + gcode += 'G40 ' + gcode += 'G54\n' + gcode += 'G80 ' + gcode += 'G90 ' + 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): + return "T3 M06" + + 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): + end_coords_xy = p['xy_end'] + gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n") + + if end_coords_xy and end_coords_xy != '': + gcode += 'G00 X{x} Y{y}'.format(x=end_coords_xy[0], y=end_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' + + def test_function(self, p): + return '(HALLO)' \ No newline at end of file diff --git a/carvera_iso.py b/carvera_iso.py new file mode 100644 index 0000000..4618342 --- /dev/null +++ b/carvera_iso.py @@ -0,0 +1,170 @@ +# ########################################################## +# FlatCAM: 2D Post-processing for Manufacturing # +# http://flatcam.org # +# File Author: Matthieu Berthomé # +# Date: 5/26/2017 # +# MIT Licence # +# ########################################################## + +from appPreProcessor import * + + +class carvera_ISO(PreProc): + + include_header = True + coordinate_format = "%.*f" + feedrate_format = '%.*f' + + def start_code(self, p): + units = ' ' + str(p['units']).lower() + coords_xy = p['xy_toolchange'] + end_coords_xy = p['xy_end'] + gcode = '(This preprocessor is a test for the Carvera from Makera.)\n' + gcode += '(It is made to work with the Carvera)\n\n' + + 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_XY: ' + str(p['feedrate']) + units + '/min' + ')\n' + 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 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' + + elif str(p['options']['type']) == 'Excellon' and p['use_ui'] is True: + gcode += '\n(TOOLS DIAMETER: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Dia: %s' % str(val["tooldia"]) + ')\n' + + gcode += '\n(FEEDRATE Z: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate: %s' % \ + str(val['data']["tools_drill_feedrate_z"]) + ')\n' + + gcode += '\n(FEEDRATE RAPIDS: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Feedrate Rapids: %s' % \ + str(val['data']["tools_drill_feedrate_rapid"]) + ')\n' + + gcode += '\n(Z_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Cut: %s' % str(val['data']["tools_drill_cutz"]) + ')\n' + + gcode += '\n(Tools Offset: )\n' + for tool, val in p['exc_cnc_tools'].items(): + gcode += '(Tool: %s -> ' % str(val['tool']) + 'Offset Z: %s' % \ + str(val['data']["tools_drill_offset"]) + ')\n' + + if p['multidepth'] is True: + gcode += '\n(DEPTH_PER_CUT: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'DeptPerCut: %s' % \ + str(val['data']["tools_drill_depthperpass"]) + ')\n' + + gcode += '\n(Z_MOVE: )\n' + for tool, val in p['exc_tools'].items(): + gcode += '(Tool: %s -> ' % str(tool) + 'Z_Move: %s' % str(val['data']["tools_drill_travelz"]) + ')\n' + gcode += '\n' + + if p['toolchange'] is True: + 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' + if end_coords_xy is not None: + gcode += '(X,Y End: ' + "%.*f, %.*f" % (p.decimals, end_coords_xy[0], + p.decimals, end_coords_xy[1]) + units + ')\n' + else: + gcode += '(X,Y End: ' + "None" + 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 ' if p.units.upper() == 'IN' else 'G21 ') + gcode += 'G40 ' + gcode += 'G54\n' + gcode += 'G80 ' + gcode += 'G90 ' + 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): + return "T2 M06" + + 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): + end_coords_xy = p['xy_end'] + gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n") + + if end_coords_xy and end_coords_xy != '': + gcode += 'G00 X{x} Y{y}'.format(x=end_coords_xy[0], y=end_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' + + def test_function(self, p): + return '(HALLO)' \ No newline at end of file