Commit 3944be3e authored by sumpfralle's avatar sumpfralle

cleanup of gcode generation:

 * first move is always up to safety height (before: diagonal movement starting from the current position)
 * removed "start position" - it is not relevant for the resulting gcode


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@527 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 59f31c22
...@@ -29,7 +29,7 @@ import os ...@@ -29,7 +29,7 @@ import os
class SimpleGCodeExporter: class SimpleGCodeExporter:
def __init__(self, destination, unit, startx, starty, startz, feedrate, def __init__(self, destination, unit, 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, comment=None): max_skip_safety_distance=None, comment=None):
self._last_path_point = None self._last_path_point = None
...@@ -50,14 +50,12 @@ class SimpleGCodeExporter: ...@@ -50,14 +50,12 @@ class SimpleGCodeExporter:
self.destination.write("G21\n") self.destination.write("G21\n")
else: else:
self.destination.write("G20\n") self.destination.write("G20\n")
self.gcode = gcode(startx, starty, startz, safetyheight=safety_height, self.gcode = gcode(safetyheight=safety_height, tool_id=tool_id)
tool_id=tool_id)
gc = self.gcode
self._finish_program_on_exit = finish_program self._finish_program_on_exit = finish_program
self.destination.write(gc.begin() + "\n") self.destination.write(self.gcode.begin() + "\n")
self.destination.write("F" + str(feedrate) + "\n") self.destination.write("F" + str(feedrate) + "\n")
self.destination.write("S" + str(speed) + "\n") self.destination.write("S" + str(speed) + "\n")
self.destination.write(gc.safety() + "\n") self.destination.write(self.gcode.safety() + "\n")
def close(self): def close(self):
gc = self.gcode gc = self.gcode
...@@ -104,10 +102,8 @@ class SimpleGCodeExporter: ...@@ -104,10 +102,8 @@ class SimpleGCodeExporter:
self._last_path_point.y, self.gcode.safetyheight) + "\n") self._last_path_point.y, self.gcode.safetyheight) + "\n")
def ExportPathList(destination, pathlist, unit, startx, starty, startz, def ExportPathList(destination, pathlist, unit, feedrate, speed, **kwargs):
feedrate, speed, **kwargs): exporter = SimpleGCodeExporter(destination, unit, feedrate, speed, **kwargs)
exporter = SimpleGCodeExporter(destination, unit, startx, starty, startz,
feedrate, speed, **kwargs)
exporter.AddPathList(pathlist) exporter.AddPathList(pathlist)
exporter.close() exporter.close()
...@@ -20,23 +20,19 @@ class gcode: ...@@ -20,23 +20,19 @@ class gcode:
lastx = lasty = lastz = lasta = lastgcode = None lastx = lasty = lastz = lasta = lastgcode = None
lastfeed = None lastfeed = None
def __init__(self, startx, starty, startz, homeheight=1.5, def __init__(self, homeheight=1.5, safetyheight=None, tool_id=1):
safetyheight=None, tool_id=1):
self.startx = startx
self.starty = starty
self.startz = startz
self.tool_id = tool_id self.tool_id = tool_id
if safetyheight is None: if safetyheight is None:
safetyheight = max(max(startz, homeheight), 0.04) safetyheight = max(homeheight, 0.04)
self.homeheight = max(startz, homeheight) self.homeheight = homeheight
self.safetyheight = safetyheight self.safetyheight = safetyheight
self.lastz = max(self.homeheight, safetyheight) self.lastz = self.safetyheight
def begin(self): def begin(self):
# no x/y positioning - just go up to safety height
return "G40 G49 G54 G80 G90\n" \ return "G40 G49 G54 G80 G90\n" \
+ "G04 P3 T%d M6\n" % self.tool_id \ + "G04 P3 T%d M6\n" % self.tool_id \
+ "G00 X%.4f Y%.4f Z%.4f\n" \ + "G00 Z%.4f\n" % self.safetyheight
% (self.startx, self.starty, self.startz)
def end(self): def end(self):
return self.safety() + "\n" + "M2\n" return self.safety() + "\n" + "M2\n"
......
...@@ -2338,7 +2338,6 @@ class ProjectGui: ...@@ -2338,7 +2338,6 @@ class ProjectGui:
is_last_loop = True is_last_loop = True
else: else:
is_last_loop = False is_last_loop = False
start_pos = tp.get_start_position()
settings = tp.get_toolpath_settings() settings = tp.get_toolpath_settings()
process = settings.get_process_settings() process = settings.get_process_settings()
tool = settings.get_tool_settings() tool = settings.get_tool_settings()
...@@ -2346,9 +2345,9 @@ class ProjectGui: ...@@ -2346,9 +2345,9 @@ class ProjectGui:
meta_data.append(self.get_meta_data()) meta_data.append(self.get_meta_data())
meta_data.append(tp.get_meta_data()) meta_data.append(tp.get_meta_data())
pycam.Exporters.SimpleGCodeExporter.ExportPathList(destination, pycam.Exporters.SimpleGCodeExporter.ExportPathList(destination,
tp.get_path(), settings.get_unit_size(), start_pos.x, tp.get_path(), settings.get_unit_size(),
start_pos.y, start_pos.z, tool["feedrate"], tool["feedrate"], tool["speed"],
tool["speed"], safety_height=process["safety_height"], safety_height=process["safety_height"],
tool_id=tool["id"], finish_program=is_last_loop, tool_id=tool["id"], finish_program=is_last_loop,
max_skip_safety_distance=2*tool["tool_radius"], max_skip_safety_distance=2*tool["tool_radius"],
comment=os.linesep.join(meta_data)) comment=os.linesep.join(meta_data))
......
...@@ -79,16 +79,6 @@ class ToolPath: ...@@ -79,16 +79,6 @@ class ToolPath:
def get_path(self): def get_path(self):
return self.toolpath return self.toolpath
def get_start_position(self):
safety_height = \
self.toolpath_settings.get_process_settings()["safety_height"]
for path in self.toolpath:
if path.points:
p = path.points[0]
return Point(p.x, p.y, safety_height)
else:
return Point(0, 0, safety_height)
def get_bounding_box(self): def get_bounding_box(self):
box = self.toolpath_settings.get_bounds() box = self.toolpath_settings.get_bounds()
return (box["minx"], box["maxx"], box["miny"], box["maxy"], box["minz"], return (box["minx"], box["maxx"], box["miny"], box["maxy"], box["minz"],
......
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