Commit 834891fb authored by sumpfralle's avatar sumpfralle

omit unnecessary moves to safety height between adjacent paths


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@335 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0198d027
Version 0.2.5 - NOT RELEASED Version 0.2.5 - NOT RELEASED
* changing the unit (mm/inch) now opens a dialog for scaling the model, * changing the unit (mm/inch) now opens a dialog for scaling the model,
processing dimensions or tool dimensions accordingly processing dimensions or tool dimensions accordingly
* remove unnecessary moves to safety height
* changed name of configuration setting "overlap" to "overlap_percent" * changed name of configuration setting "overlap" to "overlap_percent"
(you may need to change this name in your custom config files) (you may need to change this name in your custom config files)
......
...@@ -29,7 +29,10 @@ from gcode import gcode ...@@ -29,7 +29,10 @@ from gcode import gcode
class SimpleGCodeExporter: class SimpleGCodeExporter:
def __init__(self, destination, unit, startx, starty, startz, feedrate, def __init__(self, destination, unit, startx, starty, startz, feedrate,
speed, safety_height=None, tool_id=1, finish_program=False): speed, safety_height=None, tool_id=1, finish_program=False,
max_skip_safety_distance=None):
self._last_path_point = None
self._max_skip_safety_distance = max_skip_safety_distance
if isinstance(destination, basestring): if isinstance(destination, basestring):
# open the file # open the file
self.destination = file(destination,"w") self.destination = file(destination,"w")
...@@ -60,24 +63,41 @@ class SimpleGCodeExporter: ...@@ -60,24 +63,41 @@ class SimpleGCodeExporter:
if self._close_stream_on_exit: if self._close_stream_on_exit:
self.destination.close() self.destination.close()
def _check_distance_for_skipping_safety_height(self, new_point):
if (self._last_path_point is None) or (self._max_skip_safety_distance is None):
return False
distance = new_point.sub(self._last_path_point).norm()
return distance <= self._max_skip_safety_distance
def AddPath(self, path): def AddPath(self, path):
gc = self.gcode gc = self.gcode
point = path.points[0] point = path.points[0]
self.destination.write(gc.rapid(point.x, point.y, gc.safetyheight) + "\n") # first move to the safety height if the distance to the last point
# does not exceed the given maximum
if not self._check_distance_for_skipping_safety_height(point):
# move to safety height at the end of the previous path
if not self._last_path_point is None:
self.destination.write(gc.rapid(self._last_path_point.x,
self._last_path_point.y, gc.safetyheight) + "\n")
# move to safety height for the start of the current path
self.destination.write(gc.rapid(point.x, point.y, gc.safetyheight) + "\n")
for point in path.points: for point in path.points:
self.destination.write(gc.cut(point.x, point.y, point.z) + "\n") self.destination.write(gc.cut(point.x, point.y, point.z) + "\n")
self.destination.write(gc.rapid(point.x, point.y, gc.safetyheight) + "\n") self._last_path_point = point
def AddPathList(self, pathlist): def AddPathList(self, pathlist):
for path in pathlist: for path in pathlist:
self.AddPath(path) self.AddPath(path)
# add the move to safety height to the last path
if not self._last_path_point is None:
self.destination.write(self.gcode.rapid(self._last_path_point.x,
self._last_path_point.y, self.gcode.safetyheight) + "\n")
def ExportPathList(destination, pathlist, unit, startx, starty, startz, def ExportPathList(destination, pathlist, unit, startx, starty, startz,
feedrate, speed, safety_height=None, tool_id=1, finish_program=False): feedrate, speed, **kwargs):
exporter = SimpleGCodeExporter(destination, unit, startx, starty, startz, exporter = SimpleGCodeExporter(destination, unit, startx, starty, startz,
feedrate, speed, safety_height=safety_height, tool_id=tool_id, feedrate, speed, **kwargs)
finish_program=finish_program)
exporter.AddPathList(pathlist) exporter.AddPathList(pathlist)
exporter.close() exporter.close()
...@@ -1761,8 +1761,9 @@ class ProjectGui: ...@@ -1761,8 +1761,9 @@ class ProjectGui:
pycam.Exporters.SimpleGCodeExporter.ExportPathList(destination, pycam.Exporters.SimpleGCodeExporter.ExportPathList(destination,
tp.toolpath, tp.unit, tp.toolpath, tp.unit,
tp.start_x, tp.start_y, tp.start_z, tp.start_x, tp.start_y, tp.start_z,
tp.feedrate, tp.speed, tp.safety_height, tp.tool_id, tp.feedrate, tp.speed, safety_height=tp.safety_height, tool_id=tp.tool_id,
finish_program=is_last_loop) finish_program=is_last_loop,
max_skip_safety_distance=2*tp.tool_settings["radius"])
destination.close() destination.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)
......
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