- 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
|
||||
- some fixes in the GCode Editor regarding the new changes in the data structure
|
||||
- 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
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
|
||||
self.prepend_snippet = ''
|
||||
self.append_snippet = ''
|
||||
self.gc_header = self.gcode_header()
|
||||
self.gc_header = ''
|
||||
self.gc_start = ''
|
||||
self.gc_end = ''
|
||||
|
||||
@@ -473,7 +473,6 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
# #############################################################################################################
|
||||
# ##################################### SIGNALS CONNECTIONS ###################################################
|
||||
# #############################################################################################################
|
||||
|
||||
self.ui.level.toggled.connect(self.on_level_changed)
|
||||
|
||||
# annotation signal
|
||||
@@ -525,6 +524,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
if self.append_snippet != '' or self.prepend_snippet != '':
|
||||
preamble = self.prepend_snippet
|
||||
postamble = self.append_snippet
|
||||
|
||||
self.gc_header = self.gcode_header()
|
||||
gc = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True)
|
||||
|
||||
# set the Source File attribute with the calculated GCode
|
||||
@@ -820,15 +821,17 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
marlin = False
|
||||
hpgl = False
|
||||
probe_pp = False
|
||||
nccad_pp = False
|
||||
|
||||
gcode = ''
|
||||
|
||||
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 ')'
|
||||
|
||||
if self.options['type'] == 'geometry':
|
||||
if self.options['type'].lower() == 'geometry':
|
||||
try:
|
||||
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():
|
||||
marlin = True
|
||||
break
|
||||
@@ -838,24 +841,33 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
if "toolchange_probe" in ppg.lower():
|
||||
probe_pp = True
|
||||
break
|
||||
except KeyError:
|
||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e))
|
||||
if "nccad" in ppg.lower():
|
||||
nccad_pp = True
|
||||
except Exception as e:
|
||||
self.app.log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e))
|
||||
pass
|
||||
|
||||
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
|
||||
except KeyError:
|
||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
||||
pass
|
||||
|
||||
try:
|
||||
if "toolchange_probe" in self.options['ppname_e'].lower():
|
||||
if "toolchange_probe" in self.options['tools_drill_ppname_e'].lower():
|
||||
probe_pp = True
|
||||
except KeyError:
|
||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
||||
pass
|
||||
|
||||
try:
|
||||
if 'nccad' in self.options['tools_drill_ppname_e'].lower():
|
||||
nccad_pp = True
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if marlin is True:
|
||||
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'
|
||||
@@ -889,6 +901,15 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
|
||||
gcode += '(Units: ' + self.units.upper() + ')\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:
|
||||
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'
|
||||
|
||||
@@ -20,7 +20,7 @@ class NCCAD9(PreProc):
|
||||
units = ' ' + str(p['units']).lower()
|
||||
coords_xy = p['xy_toolchange']
|
||||
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'])
|
||||
xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
|
||||
@@ -89,7 +89,7 @@ class NCCAD9(PreProc):
|
||||
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'
|
||||
|
||||
gcode += ';Steps per circle: ' + str(p['steps_per_circle']) + '\n'
|
||||
|
||||
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):
|
||||
z_toolchange = p.z_toolchange
|
||||
toolchangexy = p.xy_toolchange
|
||||
|
||||
f_plunge = p.f_plunge
|
||||
|
||||
if toolchangexy is not None:
|
||||
@@ -141,16 +142,14 @@ class NCCAD9(PreProc):
|
||||
if str(p['options']['type']) == 'Excellon':
|
||||
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 = """
|
||||
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}
|
||||
M10 O6.0 ; Stop spindle
|
||||
G00 Z{z_toolchange}
|
||||
G00 X{x_toolchange} Y{y_toolchange}
|
||||
M01 Insert tool {tool}
|
||||
; 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
|
||||
""".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),
|
||||
@@ -159,13 +158,12 @@ G0 Z{z_toolchange}
|
||||
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}
|
||||
M10 O6.0 ; Stop spindle
|
||||
G00 Z{z_toolchange}
|
||||
G77 ; Move to release position
|
||||
M01 Insert tool {tool}
|
||||
;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
|
||||
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
||||
tool=int(p.tool),
|
||||
t_drills=no_drills,
|
||||
@@ -176,16 +174,14 @@ G0 Z{z_toolchange}
|
||||
return gcode
|
||||
|
||||
else:
|
||||
if toolchangexy is not None:
|
||||
if toolchangexy is not None and x_toolchange !=0.0 and y_toolchange != 0.0:
|
||||
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}
|
||||
M10 O6.0 ; Stop spindle
|
||||
G00 Z{z_toolchange}
|
||||
G00 X{x_toolchange} Y{y_toolchange}
|
||||
M01 Insert tool {tool}
|
||||
;Change to Tool Dia = {toolC}
|
||||
G76 ; Move to reference point to ensure correct coordinates after tool change
|
||||
""".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),
|
||||
@@ -193,13 +189,12 @@ G0 Z{z_toolchange}
|
||||
toolC=toolC_formatted)
|
||||
else:
|
||||
gcode = """
|
||||
M5
|
||||
G0 Z{z_toolchange}
|
||||
T{tool}
|
||||
M6
|
||||
;MSG, Change to Tool Dia = {toolC}
|
||||
M0
|
||||
G0 Z{z_toolchange}
|
||||
M10 O6.0 ; Stop spindle
|
||||
G00 Z{z_toolchange}
|
||||
G77 ; Move to release position
|
||||
M01 Insert tool {tool}
|
||||
;Change to Tool Dia = {toolC}
|
||||
G76 ; Move to reference point to ensure correct coordinates after tool change
|
||||
""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
|
||||
tool=int(p.tool),
|
||||
toolC=toolC_formatted)
|
||||
@@ -222,13 +217,18 @@ G0 Z{z_toolchange}
|
||||
return ('G01 ' + self.position_code(p)).format(**p) + " " + self.inline_feedrate_code(p)
|
||||
|
||||
def end_code(self, p):
|
||||
gcode = ''
|
||||
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 != '':
|
||||
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 += 'M10 O2.0 ;turn off high speed spindle at relay 2'
|
||||
gcode += '''
|
||||
G77 ; Move to release position
|
||||
M10 O6.0 ; Stop spindle
|
||||
'''
|
||||
return gcode
|
||||
|
||||
def feedrate_code(self, p):
|
||||
|
||||
Reference in New Issue
Block a user