Commit 84b40b66 authored by lode_leroy's avatar lode_leroy

make speed configurable

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@28 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 9fc3ffa0
...@@ -10,7 +10,7 @@ all: ...@@ -10,7 +10,7 @@ all:
.PHONY: dist .PHONY: dist
dist: dist:
(cd ..; tar zcf pycam/pycam.tgz pycam/*{Makefile,TXT,txt} pycam/*.py pycam/tests/*.py pycam/pycam/*/*.py pycam/pycam/*.py pycam/Samples/*/*.stl) (cd ..; tar zcf pycam/pycam.tgz pycam/*{Makefile,TXT} pycam/*.py pycam/tests/*.py pycam/pycam/*/*.py pycam/pycam/*.py pycam/Samples/*/*.stl)
dist-ver: dist-ver:
(cd ..; tar zcf pycam-$(VER)/pycam-$(VER).tgz pycam-$(VER)/*{Makefile,TXT} pycam-$(VER)/*.py pycam-$(VER)/tests/*.py pycam-$(VER)/pycam/*/*.py pycam-$(VER)/pycam/*.py pycam-$(VER)/Samples/*/*.stl) (cd ..; tar zcf pycam-$(VER)/pycam-$(VER).tgz pycam-$(VER)/*{Makefile,TXT} pycam-$(VER)/*.py pycam-$(VER)/tests/*.py pycam-$(VER)/pycam/*/*.py pycam-$(VER)/pycam/*.py pycam-$(VER)/Samples/*/*.stl)
......
...@@ -5,17 +5,19 @@ from gcode import gcode ...@@ -5,17 +5,19 @@ from gcode import gcode
class SimpleGCodeExporter: class SimpleGCodeExporter:
def __init__(self, filename, unit, x, y, z): def __init__(self, filename, unit, x, y, z, feedrate, speed):
self.file = file(filename,"w") self.file = file(filename,"w")
if unit == "mm": if unit == "mm":
self.file.write("G20\n") self.file.write("G21\n")
z += 7.0 z += 7.0
else: else:
self.file.write("G21\n") self.file.write("G20\n")
z += 0.25 z += 0.25
self.gcode = gcode(x,y,z) 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("F"+feedrate+"\n")
self.file.write("S"+speed+"\n")
self.file.write(gc.safety()+"\n") self.file.write(gc.safety()+"\n")
def close(self): def close(self):
...@@ -27,18 +29,18 @@ class SimpleGCodeExporter: ...@@ -27,18 +29,18 @@ class SimpleGCodeExporter:
def AddPath(self, path): def AddPath(self, path):
gc = self.gcode gc = self.gcode
point = path.points[0] point = path.points[0]
self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n") # self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
for point in path.points: for point in path.points:
self.file.write(gc.cut(point.x,point.y,point.z)+"\n") self.file.write(gc.cut(point.x,point.y,point.z)+"\n")
self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n") # self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
def AddPathList(self, pathlist): def AddPathList(self, pathlist):
for path in pathlist: for path in pathlist:
self.AddPath(path) self.AddPath(path)
def ExportPathList(filename, pathlist, unit, x, y, z): def ExportPathList(filename, pathlist, unit, x, y, z, feedrate, speed):
exporter = SimpleGCodeExporter(filename, unit, x, y, z) exporter = SimpleGCodeExporter(filename, unit, x, y, z, feedrate, speed)
exporter.AddPathList(pathlist) exporter.AddPathList(pathlist)
exporter.close() exporter.close()
...@@ -25,7 +25,6 @@ class gcode: ...@@ -25,7 +25,6 @@ class gcode:
def begin(self): def begin(self):
return "G40 G49 G54 G80 G90\n" + \ return "G40 G49 G54 G80 G90\n" + \
"S1000 F10\n" + \
"G04 P3 T1 M6\n" + \ "G04 P3 T1 M6\n" + \
"G00 X%.4f Y%.4f Z%.4f\n" % (self.startx, self.starty, self.startz) "G00 X%.4f Y%.4f Z%.4f\n" % (self.startx, self.starty, self.startz)
......
...@@ -265,7 +265,7 @@ class SimpleGui(Frame): ...@@ -265,7 +265,7 @@ class SimpleGui(Frame):
self.ogl.tkRedraw() self.ogl.tkRedraw()
def browseSaveAs(self): def browseSaveAs(self):
filename = tkFileDialog.SaveAs(self, filetypes=[("GCODE files", ".nc .gc")]).show() filename = tkFileDialog.SaveAs(self, filetypes=[("GCODE files", ".nc .gc .ngc")]).show()
if filename: if filename:
self.OutputFileName.set(filename) self.OutputFileName.set(filename)
if self.toolpath: if self.toolpath:
...@@ -276,10 +276,10 @@ class SimpleGui(Frame): ...@@ -276,10 +276,10 @@ class SimpleGui(Frame):
maxy = float(self.MaxY.get())+offset maxy = float(self.MaxY.get())+offset
minz = float(self.MinZ.get())-offset minz = float(self.MinZ.get())-offset
maxz = float(self.MaxZ.get())+offset maxz = float(self.MaxZ.get())+offset
exporter = SimpleGCodeExporter.ExportPathList(filename, self.toolpath, self.Unit, minx, miny, maxz) exporter = SimpleGCodeExporter.ExportPathList(filename, self.toolpath, self.Unit.get(), minx, miny, maxz, self.FeedRate.get(), self.Speed.get())
def createWidgets(self): def createWidgets(self):
self.ogl = OpenglWidget(self, width=600, height=500) self.ogl = OpenglWidget(self, width=600, height=500, double=1)
self.TopFrame = Frame(self).pack(side=TOP, expand=0, fill=X) self.TopFrame = Frame(self).pack(side=TOP, expand=0, fill=X)
...@@ -393,6 +393,17 @@ class SimpleGui(Frame): ...@@ -393,6 +393,17 @@ class SimpleGui(Frame):
Label(self.OutputFileFrame, text= "Output File: ").pack(side=LEFT) Label(self.OutputFileFrame, text= "Output File: ").pack(side=LEFT)
self.OutputFileName = StringVar() self.OutputFileName = StringVar()
self.OutputFileField = Entry(self.OutputFileFrame, textvariable=self.OutputFileName).pack(side=LEFT, expand=1, fill=X) self.OutputFileField = Entry(self.OutputFileFrame, textvariable=self.OutputFileName).pack(side=LEFT, expand=1, fill=X)
self.FeedRate = StringVar()
self.FeedRate.set("200")
Label(self.OutputFileFrame, text="FeedRate").pack(side=LEFT)
Entry(self.OutputFileFrame, textvariable=self.FeedRate, width=6).pack(side=LEFT)
self.Speed = StringVar()
self.Speed.set("1000")
Label(self.OutputFileFrame, text="Speed").pack(side=LEFT)
Entry(self.OutputFileFrame, textvariable=self.Speed, width=6).pack(side=LEFT)
self.OutputFileBrowse = Button(self.OutputFileFrame, text="Export...", command=self.browseSaveAs).pack(side=RIGHT) self.OutputFileBrowse = Button(self.OutputFileFrame, text="Export...", command=self.browseSaveAs).pack(side=RIGHT)
self.ViewFrame = Frame(self.TopFrame) self.ViewFrame = Frame(self.TopFrame)
......
...@@ -28,6 +28,7 @@ class DropCutter: ...@@ -28,6 +28,7 @@ class DropCutter:
z_max = -INFINITE z_max = -INFINITE
cl_max = None cl_max = None
t_max = None t_max = None
cl_last = None
self.cutter.moveto(p) self.cutter.moveto(p)
for t in self.model.triangles(): for t in self.model.triangles():
if t.normal().z < 0: continue; if t.normal().z < 0: continue;
...@@ -39,7 +40,7 @@ class DropCutter: ...@@ -39,7 +40,7 @@ class DropCutter:
if not cl_max or cl_max.z<z0: if not cl_max or cl_max.z<z0:
cl_max = Point(x,y,z0) cl_max = Point(x,y,z0)
if (t_max and not t_last) or (t_last and not t_max): if cl_last and ((t_max and not t_last) or (t_last and not t_max)):
if cl_last.z < z_max: if cl_last.z < z_max:
pa.append(Point(cl_last.x,cl_last.y,cl_max.z)) pa.append(Point(cl_last.x,cl_last.y,cl_max.z))
else: else:
......
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