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