Commit 728514ac authored by sumpfralle's avatar sumpfralle

allow assembling of multiple toolpaths into one gcode output file


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@176 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent c148938f
...@@ -768,9 +768,7 @@ class ProjectGui: ...@@ -768,9 +768,7 @@ class ProjectGui:
for tp in self.toolpath: for tp in self.toolpath:
items = (tp.name, tp.visible, tp.drill_size, items = (tp.name, tp.visible, tp.drill_size,
tp.drill_id, tp.material_allowance, tp.speed, tp.feedrate) tp.drill_id, tp.material_allowance, tp.speed, tp.feedrate)
print items
self.toolpath_model.append(items) self.toolpath_model.append(items)
#print dir(self.toolpath_table)
@gui_activity_guard @gui_activity_guard
def save_processing_settings_file(self, widget=None, section=None): def save_processing_settings_file(self, widget=None, section=None):
...@@ -915,11 +913,21 @@ class ProjectGui: ...@@ -915,11 +913,21 @@ class ProjectGui:
elif direction == "xy": elif direction == "xy":
toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dy, dz, draw_callback) toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dy, dz, draw_callback)
print "Time elapsed: %f" % (time.time() - start_time) print "Time elapsed: %f" % (time.time() - start_time)
# calculate the z offset for the starting position
# TODO: fix these hard-coded offsets; maybe use the safety height instead?
if self.settings.get("unit") == 'mm':
start_offset = 7.0
else:
start_offset = 0.25
self.toolpath.add_toolpath(toolpath, self.toolpath.add_toolpath(toolpath,
self.processing_config_selection.get_active_text(), cutter, self.processing_config_selection.get_active_text(),
cutter,
self.settings.get("speed"), self.settings.get("speed"),
self.settings.get("feedrate"), self.settings.get("feedrate"),
self.settings.get("material_allowance")) self.settings.get("material_allowance"),
self.settings.get("safety_height"),
self.settings.get("unit"),
minx, miny, maxz + start_offset)
self.update_toolpath_table() self.update_toolpath_table()
self.update_view() self.update_view()
...@@ -974,37 +982,34 @@ class ProjectGui: ...@@ -974,37 +982,34 @@ class ProjectGui:
def save_toolpath(self, widget=None, data=None): def save_toolpath(self, widget=None, data=None):
if not self.toolpath: if not self.toolpath:
return return
offset = float(self.settings.get("tool_radius"))/2
minx = float(self.settings.get("minx"))-offset
maxx = float(self.settings.get("maxx"))+offset
miny = float(self.settings.get("miny"))-offset
maxy = float(self.settings.get("maxy"))+offset
minz = float(self.settings.get("minz"))-offset
maxz = float(self.settings.get("maxz"))+offset
no_dialog = False
if isinstance(widget, basestring): if isinstance(widget, basestring):
filename = widget filename = widget
no_dialog = True no_dialog = True
else: else:
# we open a dialog # we open a dialog
filename = self.get_save_filename("Save toolpath to ...", ("GCode files", ["*.gcode", "*.nc", "*.gc", "*.ngc"])) filename = self.get_save_filename("Save toolpath to ...", ("GCode files", ["*.gcode", "*.nc", "*.gc", "*.ngc"]))
no_dialog = False
# no filename given -> exit # no filename given -> exit
if not filename: if not filename:
return return
try: try:
fi = open(filename, "w") destination = open(filename, "w")
# TODO: fix these hard-coded offsets index = 0
if self.settings.get("unit") == 'mm': for index in range(len(self.toolpath)):
start_offset = 7.0 tp = self.toolpath[index]
# check if this is the last loop iteration
# only the last toolpath of the list should contain the "M2"
# ("end program") G-code
if index + 1 == len(self.toolpath):
is_last_loop = True
else: else:
start_offset = 0.25 is_last_loop = False
exporter = pycam.Exporters.SimpleGCodeExporter.ExportPathList( pycam.Exporters.SimpleGCodeExporter.ExportPathList(destination,
filename, self.toolpath[0].get_path, self.settings.get("unit"), tp.toolpath, tp.unit,
minx, miny, maxz + start_offset, tp.start_x, tp.start_y, tp.start_z,
self.settings.get("feedrate"), tp.feedrate, tp.speed, tp.safety_height, tp.drill_id,
self.settings.get("speed"), finish_program=is_last_loop)
safety_height=self.settings.get("safety_height")) destination.close()
fi.close()
if self.no_dialog: if self.no_dialog:
print "GCode file successfully written: %s" % str(filename) print "GCode file successfully written: %s" % str(filename)
except IOError, err_msg: except IOError, err_msg:
......
...@@ -209,9 +209,9 @@ def is_ode_available(): ...@@ -209,9 +209,9 @@ def is_ode_available():
class ToolPathList(list): class ToolPathList(list):
def add_toolpath(self, toolpath, name, cutter, speed, feedrate, material_allowance): def add_toolpath(self, toolpath, name, cutter, *args):
drill_id = self._get_drill_id(cutter) drill_id = self._get_drill_id(cutter)
self.append(ToolPathInfo(toolpath, name, drill_id, cutter, speed, feedrate, material_allowance)) self.append(ToolPathInfo(toolpath, name, drill_id, cutter, *args))
def _get_drill_id(self, cutter): def _get_drill_id(self, cutter):
used_ids = [] used_ids = []
...@@ -230,7 +230,8 @@ class ToolPathList(list): ...@@ -230,7 +230,8 @@ class ToolPathList(list):
class ToolPathInfo: class ToolPathInfo:
def __init__(self, toolpath, name, drill_id, cutter, speed, feedrate, material_allowance): def __init__(self, toolpath, name, drill_id, cutter, speed, feedrate,
material_allowance, safety_height, unit, start_x, start_y, start_z):
self.toolpath = toolpath self.toolpath = toolpath
self.name = name self.name = name
self.visible = True self.visible = True
...@@ -240,6 +241,11 @@ class ToolPathInfo: ...@@ -240,6 +241,11 @@ class ToolPathInfo:
self.speed = speed self.speed = speed
self.feedrate = feedrate self.feedrate = feedrate
self.material_allowance = material_allowance self.material_allowance = material_allowance
self.safety_height = safety_height
self.unit = unit
self.start_x = start_x
self.start_y = start_y
self.start_z = start_z
self.color = None self.color = None
# generate random color # generate random color
self.set_color() self.set_color()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment