Commit 406b32f2 authored by lode_leroy's avatar lode_leroy

make tool come outside the stock while cutting

make safetyheight higher than stock



git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@13 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 8c16074d
......@@ -5,9 +5,15 @@ from gcode import gcode
class SimpleGCodeExporter:
def __init__(self, filename, safetyheight=7.0, homeheight=7.0):
def __init__(self, filename, unit, x, y, z):
self.file = file(filename,"w")
self.gcode = gcode(homeheight, safetyheight)
if unit == "mm":
self.file.write("G20\n")
z += 7.0
else:
self.file.write("G21\n")
z += 0.25
self.gcode = gcode(x,y,z)
gc = self.gcode
self.file.write(gc.begin()+"\n")
self.file.write(gc.safety()+"\n")
......@@ -31,12 +37,8 @@ class SimpleGCodeExporter:
self.AddPath(path)
def ExportPathList(filename, pathlist, unit):
exporter = SimpleGCodeExporter(filename)
if unit == "mm":
exporter.file.write("G20\n")
else:
exporter.file.write("G21\n")
def ExportPathList(filename, pathlist, unit, x, y, z):
exporter = SimpleGCodeExporter(filename, unit, x, y, z)
exporter.AddPathList(pathlist)
exporter.close()
......@@ -16,15 +16,18 @@ class gcode:
lastx = lasty = lastz = lasta = lastgcode = None
lastfeed = None
def __init__(self, homeheight = 1.5, safetyheight = 0.04):
self.homeheight = homeheight
self.safetyheight = self.lastz = safetyheight
def __init__(self, startx, starty, startz, homeheight = 1.5, safetyheight = 0.04):
self.startx = startx
self.starty = starty
self.startz = startz
self.homeheight = max(startz,homeheight)
self.safetyheight = self.lastz = max(self.homeheight,safetyheight)
def begin(self):
return "G00 Z%.4f\n" % (self.safetyheight) + \
"G17 G40 G49\n" + "G54 G80 G90 G94\n" + \
"S1000 M3\n" + "G04 P3" + \
"T1 M6 F0.1\n"
return "G40 G49 G54 G80 G90\n" + \
"S1000 F10\n" + \
"G04 P3 T1 M6\n" + \
"G00 X%.4f Y%.4f Z%.4f\n" % (self.startx, self.starty, self.startz)
def end(self):
return self.safety() + "\n" + "M2\n"
......
......@@ -164,12 +164,14 @@ class SimpleGui(Frame):
toroid = float(self.ToroidRadius.get())
self.cutter = ToroidalCutter(radius, toroid)
minx = float(self.MinX.get())
maxx = float(self.MaxX.get())
miny = float(self.MinY.get())
maxy = float(self.MaxY.get())
minz = float(self.MinZ.get())
maxz = float(self.MaxZ.get())
offset = radius/2
minx = float(self.MinX.get())-offset
maxx = float(self.MaxX.get())+offset
miny = float(self.MinY.get())-offset
maxy = float(self.MaxY.get())+offset
minz = float(self.MinZ.get())-offset
maxz = float(self.MaxZ.get())+offset
samples = float(self.Samples.get())
lines = float(self.Lines.get())
layers = float(self.Layers.get())
......@@ -216,7 +218,14 @@ class SimpleGui(Frame):
if filename:
self.OutputFileName.set(filename)
if self.toolpath:
exporter = SimpleGCodeExporter.ExportPathList(filename, self.toolpath, self.Unit)
offset = float(self.CutterRadius.get())/2
minx = float(self.MinX.get())-offset
maxx = float(self.MaxX.get())+offset
miny = float(self.MinY.get())-offset
maxy = float(self.MaxY.get())+offset
minz = float(self.MinZ.get())-offset
maxz = float(self.MaxZ.get())+offset
exporter = SimpleGCodeExporter.ExportPathList(filename, self.toolpath, self.Unit, minx, miny, maxz)
def createWidgets(self):
self.ogl = OpenglWidget(self, width=600, height=500)
......@@ -429,7 +438,7 @@ class SimpleGui(Frame):
self.ogl.tkRedraw()
if __name__ == "__main__":
app = SimpleGui()
app.model = TestModel.TestModel()
......
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