- finished preprocessor file for Kosy CNC machine (NCCAD9)
- fixed the gcode header export to work with the new data structure
This commit is contained in:
@@ -13,6 +13,8 @@ CHANGELOG for FlatCAM beta
|
|||||||
- Fixed the SolderPaste Plugin regarding the special designation 'SP' job type and 'DN' tool shape
|
- Fixed the SolderPaste Plugin regarding the special designation 'SP' job type and 'DN' tool shape
|
||||||
- some fixes in the GCode Editor regarding the new changes in the data structure
|
- some fixes in the GCode Editor regarding the new changes in the data structure
|
||||||
- some updates to the language strings
|
- some updates to the language strings
|
||||||
|
- finished preprocessor file for Kosy CNC machine (NCCAD9)
|
||||||
|
- fixed the gcode header export to work with the new data structure
|
||||||
|
|
||||||
15.07.2021
|
15.07.2021
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||||||
|
|
||||||
self.prepend_snippet = ''
|
self.prepend_snippet = ''
|
||||||
self.append_snippet = ''
|
self.append_snippet = ''
|
||||||
self.gc_header = self.gcode_header()
|
self.gc_header = ''
|
||||||
self.gc_start = ''
|
self.gc_start = ''
|
||||||
self.gc_end = ''
|
self.gc_end = ''
|
||||||
|
|
||||||
@@ -473,7 +473,6 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||||||
# #############################################################################################################
|
# #############################################################################################################
|
||||||
# ##################################### SIGNALS CONNECTIONS ###################################################
|
# ##################################### SIGNALS CONNECTIONS ###################################################
|
||||||
# #############################################################################################################
|
# #############################################################################################################
|
||||||
|
|
||||||
self.ui.level.toggled.connect(self.on_level_changed)
|
self.ui.level.toggled.connect(self.on_level_changed)
|
||||||
|
|
||||||
# annotation signal
|
# annotation signal
|
||||||
@@ -525,6 +524,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||||||
if self.append_snippet != '' or self.prepend_snippet != '':
|
if self.append_snippet != '' or self.prepend_snippet != '':
|
||||||
preamble = self.prepend_snippet
|
preamble = self.prepend_snippet
|
||||||
postamble = self.append_snippet
|
postamble = self.append_snippet
|
||||||
|
|
||||||
|
self.gc_header = self.gcode_header()
|
||||||
gc = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True)
|
gc = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True)
|
||||||
|
|
||||||
# set the Source File attribute with the calculated GCode
|
# set the Source File attribute with the calculated GCode
|
||||||
@@ -820,15 +821,17 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||||||
marlin = False
|
marlin = False
|
||||||
hpgl = False
|
hpgl = False
|
||||||
probe_pp = False
|
probe_pp = False
|
||||||
|
nccad_pp = False
|
||||||
|
|
||||||
gcode = ''
|
gcode = ''
|
||||||
|
|
||||||
start_comment = comment_start_symbol if comment_start_symbol is not None else '('
|
start_comment = comment_start_symbol if comment_start_symbol is not None else '('
|
||||||
stop_comment = comment_stop_symbol if comment_stop_symbol is not None else ')'
|
stop_comment = comment_stop_symbol if comment_stop_symbol is not None else ')'
|
||||||
|
|
||||||
if self.options['type'] == 'geometry':
|
if self.options['type'].lower() == 'geometry':
|
||||||
try:
|
try:
|
||||||
for key in self.tools:
|
for key in self.tools:
|
||||||
ppg = self.tools[key]['data']['ppname_g']
|
ppg = self.tools[key]['data']['tools_mill_ppname_g']
|
||||||
if 'marlin' in ppg.lower() or 'repetier' in ppg.lower():
|
if 'marlin' in ppg.lower() or 'repetier' in ppg.lower():
|
||||||
marlin = True
|
marlin = True
|
||||||
break
|
break
|
||||||
@@ -838,24 +841,33 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||||||
if "toolchange_probe" in ppg.lower():
|
if "toolchange_probe" in ppg.lower():
|
||||||
probe_pp = True
|
probe_pp = True
|
||||||
break
|
break
|
||||||
except KeyError:
|
if "nccad" in ppg.lower():
|
||||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e))
|
nccad_pp = True
|
||||||
|
except Exception as e:
|
||||||
|
self.app.log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if 'marlin' in self.options['ppname_e'].lower() or 'repetier' in self.options['ppname_e'].lower():
|
if 'marlin' in self.options['tools_drill_ppname_e'].lower() or \
|
||||||
|
'repetier' in self.options['tools_drill_ppname_e'].lower():
|
||||||
marlin = True
|
marlin = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if "toolchange_probe" in self.options['ppname_e'].lower():
|
if "toolchange_probe" in self.options['tools_drill_ppname_e'].lower():
|
||||||
probe_pp = True
|
probe_pp = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if 'nccad' in self.options['tools_drill_ppname_e'].lower():
|
||||||
|
nccad_pp = True
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
if marlin is True:
|
if marlin is True:
|
||||||
gcode += ';Marlin(Repetier) G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s\n' % \
|
gcode += ';Marlin(Repetier) G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s\n' % \
|
||||||
(str(self.app.version), str(self.app.version_date)) + '\n'
|
(str(self.app.version), str(self.app.version_date)) + '\n'
|
||||||
@@ -889,6 +901,15 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||||||
|
|
||||||
gcode += '(Units: ' + self.units.upper() + ')\n' + "\n"
|
gcode += '(Units: ' + self.units.upper() + ')\n' + "\n"
|
||||||
gcode += '(Created on ' + time_str + ')\n' + '\n'
|
gcode += '(Created on ' + time_str + ')\n' + '\n'
|
||||||
|
elif nccad_pp is True:
|
||||||
|
gcode += ';NCCAD9 G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s\n' % \
|
||||||
|
(str(self.app.version), str(self.app.version_date)) + '\n'
|
||||||
|
|
||||||
|
gcode += ';Name: ' + str(self.options['name']) + '\n'
|
||||||
|
gcode += ';Type: ' + "G-code from " + str(self.options['type']) + '\n'
|
||||||
|
|
||||||
|
gcode += ';Units: ' + self.units.upper() + '\n' + "\n"
|
||||||
|
gcode += ';Created on ' + time_str + '\n' + '\n'
|
||||||
else:
|
else:
|
||||||
gcode += '%sG-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s%s\n' % \
|
gcode += '%sG-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s%s\n' % \
|
||||||
(start_comment, str(self.app.version), str(self.app.version_date), stop_comment) + '\n'
|
(start_comment, str(self.app.version), str(self.app.version_date), stop_comment) + '\n'
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class NCCAD9(PreProc):
|
|||||||
units = ' ' + str(p['units']).lower()
|
units = ' ' + str(p['units']).lower()
|
||||||
coords_xy = p['xy_toolchange']
|
coords_xy = p['xy_toolchange']
|
||||||
end_coords_xy = p['xy_end']
|
end_coords_xy = p['xy_end']
|
||||||
gcode = ';This preprocessor outputs GCode suitable for the Max Computer GmbH nccad9 Computer Numeric Control.'
|
gcode = ';This preprocessor outputs GCode suitable for the Max Computer GmbH nccad9 Computer Numeric Control.\n'
|
||||||
|
|
||||||
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
|
xmin = '%.*f' % (p.coords_decimals, p['options']['xmin'])
|
||||||
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
|
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
|
||||||
@@ -89,7 +89,7 @@ class NCCAD9(PreProc):
|
|||||||
p.decimals, end_coords_xy[1]) + units + '\n'
|
p.decimals, end_coords_xy[1]) + units + '\n'
|
||||||
else:
|
else:
|
||||||
gcode += ';X,Y End: ' + "None" + units + '\n'
|
gcode += ';X,Y End: ' + "None" + units + '\n'
|
||||||
gcode += '(Steps per circle: ' + str(p['steps_per_circle']) + ')\n'
|
|
||||||
gcode += ';Steps per circle: ' + str(p['steps_per_circle']) + '\n'
|
gcode += ';Steps per circle: ' + str(p['steps_per_circle']) + '\n'
|
||||||
|
|
||||||
if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
||||||
@@ -122,6 +122,7 @@ class NCCAD9(PreProc):
|
|||||||
def toolchange_code(self, p):
|
def toolchange_code(self, p):
|
||||||
z_toolchange = p.z_toolchange
|
z_toolchange = p.z_toolchange
|
||||||
toolchangexy = p.xy_toolchange
|
toolchangexy = p.xy_toolchange
|
||||||
|
|
||||||
f_plunge = p.f_plunge
|
f_plunge = p.f_plunge
|
||||||
|
|
||||||
if toolchangexy is not None:
|
if toolchangexy is not None:
|
||||||
@@ -141,16 +142,14 @@ class NCCAD9(PreProc):
|
|||||||
if str(p['options']['type']) == 'Excellon':
|
if str(p['options']['type']) == 'Excellon':
|
||||||
no_drills = p['tools'][int(p['tool'])]['nr_drills']
|
no_drills = p['tools'][int(p['tool'])]['nr_drills']
|
||||||
|
|
||||||
if toolchangexy is not None:
|
if toolchangexy is not None and x_toolchange !=0.0 and y_toolchange != 0.0:
|
||||||
gcode = """
|
gcode = """
|
||||||
M5
|
M10 O6.0 ; Stop spindle
|
||||||
G0 Z{z_toolchange}
|
G00 Z{z_toolchange}
|
||||||
G0 X{x_toolchange} Y{y_toolchange}
|
G00 X{x_toolchange} Y{y_toolchange}
|
||||||
T{tool}
|
M01 Insert tool {tool}
|
||||||
M6
|
; Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
|
||||||
;MSG, Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
|
G76 ; Move to reference point to ensure correct coordinates after tool change
|
||||||
M0
|
|
||||||
G0 Z{z_toolchange}
|
|
||||||
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
|
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
|
||||||
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
|
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
|
||||||
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
||||||
@@ -159,13 +158,12 @@ G0 Z{z_toolchange}
|
|||||||
toolC=toolC_formatted)
|
toolC=toolC_formatted)
|
||||||
else:
|
else:
|
||||||
gcode = """
|
gcode = """
|
||||||
M5
|
M10 O6.0 ; Stop spindle
|
||||||
G0 Z{z_toolchange}
|
G00 Z{z_toolchange}
|
||||||
T{tool}
|
G77 ; Move to release position
|
||||||
M6
|
M01 Insert tool {tool}
|
||||||
;MSG, Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
|
;Change to Tool Dia = {toolC}, Total drills for tool T{tool} = {t_drills}
|
||||||
M0
|
G76 ; Move to reference point to ensure correct coordinates after tool change
|
||||||
G0 Z{z_toolchange}
|
|
||||||
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
||||||
tool=int(p.tool),
|
tool=int(p.tool),
|
||||||
t_drills=no_drills,
|
t_drills=no_drills,
|
||||||
@@ -176,16 +174,14 @@ G0 Z{z_toolchange}
|
|||||||
return gcode
|
return gcode
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if toolchangexy is not None:
|
if toolchangexy is not None and x_toolchange !=0.0 and y_toolchange != 0.0:
|
||||||
gcode = """
|
gcode = """
|
||||||
M5
|
M10 O6.0 ; Stop spindle
|
||||||
G0 Z{z_toolchange}
|
G00 Z{z_toolchange}
|
||||||
G0 X{x_toolchange} Y{y_toolchange}
|
G00 X{x_toolchange} Y{y_toolchange}
|
||||||
T{tool}
|
M01 Insert tool {tool}
|
||||||
M6
|
;Change to Tool Dia = {toolC}
|
||||||
;MSG, Change to Tool Dia = {toolC}
|
G76 ; Move to reference point to ensure correct coordinates after tool change
|
||||||
M0
|
|
||||||
G0 Z{z_toolchange}
|
|
||||||
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
|
""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
|
||||||
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
|
y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
|
||||||
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
||||||
@@ -193,13 +189,12 @@ G0 Z{z_toolchange}
|
|||||||
toolC=toolC_formatted)
|
toolC=toolC_formatted)
|
||||||
else:
|
else:
|
||||||
gcode = """
|
gcode = """
|
||||||
M5
|
M10 O6.0 ; Stop spindle
|
||||||
G0 Z{z_toolchange}
|
G00 Z{z_toolchange}
|
||||||
T{tool}
|
G77 ; Move to release position
|
||||||
M6
|
M01 Insert tool {tool}
|
||||||
;MSG, Change to Tool Dia = {toolC}
|
;Change to Tool Dia = {toolC}
|
||||||
M0
|
G76 ; Move to reference point to ensure correct coordinates after tool change
|
||||||
G0 Z{z_toolchange}
|
|
||||||
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
||||||
tool=int(p.tool),
|
tool=int(p.tool),
|
||||||
toolC=toolC_formatted)
|
toolC=toolC_formatted)
|
||||||
@@ -222,13 +217,18 @@ G0 Z{z_toolchange}
|
|||||||
return ('G01 ' + self.position_code(p)).format(**p) + " " + self.inline_feedrate_code(p)
|
return ('G01 ' + self.position_code(p)).format(**p) + " " + self.inline_feedrate_code(p)
|
||||||
|
|
||||||
def end_code(self, p):
|
def end_code(self, p):
|
||||||
|
gcode = ''
|
||||||
coords_xy = p['xy_end']
|
coords_xy = p['xy_end']
|
||||||
gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n")
|
|
||||||
|
|
||||||
if coords_xy and coords_xy != '':
|
if coords_xy and coords_xy != '':
|
||||||
|
gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(
|
||||||
|
p) + "\n")
|
||||||
gcode += 'G0 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + " " + self.feedrate_rapid_code(p) + "\n"
|
gcode += 'G0 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + " " + self.feedrate_rapid_code(p) + "\n"
|
||||||
|
|
||||||
gcode += 'M10 O2.0 ;turn off high speed spindle at relay 2'
|
gcode += '''
|
||||||
|
G77 ; Move to release position
|
||||||
|
M10 O6.0 ; Stop spindle
|
||||||
|
'''
|
||||||
return gcode
|
return gcode
|
||||||
|
|
||||||
def feedrate_code(self, p):
|
def feedrate_code(self, p):
|
||||||
|
|||||||
Reference in New Issue
Block a user