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