Commit 317cf3d4 authored by lode_leroy's avatar lode_leroy

enable command line driven operation

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@30 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b8027f69
#!/usr/bin/python
import sys import sys
import os import os
...@@ -5,5 +6,29 @@ from pycam.Gui.SimpleGui import SimpleGui ...@@ -5,5 +6,29 @@ from pycam.Gui.SimpleGui import SimpleGui
from pycam.Importers.TestModel import TestModel from pycam.Importers.TestModel import TestModel
gui = SimpleGui() gui = SimpleGui()
gui.model = TestModel()
gui.mainloop() inputfile = None
outputfile = None
display = False
for arg in sys.argv[1:]:
if arg == "-gui":
display = True
elif arg[0] != '-':
if not inputfile:
inputfile = arg
elif not outputfile:
outputfile = arg
if not inputfile:
gui.model = TestModel()
gui.mainloop()
else:
gui.open(inputfile)
if display:
gui.mainloop()
else:
gui.generateToolpath()
if outputfile:
gui.save(outputfile)
...@@ -74,6 +74,7 @@ class SimpleGui(Frame): ...@@ -74,6 +74,7 @@ class SimpleGui(Frame):
glVertex3f(0,0,size) glVertex3f(0,0,size)
glEnd() glEnd()
if True:
# stock model # stock model
minx = float(self.MinX.get()) minx = float(self.MinX.get())
maxx = float(self.MaxX.get()) maxx = float(self.MaxX.get())
...@@ -147,6 +148,10 @@ class SimpleGui(Frame): ...@@ -147,6 +148,10 @@ class SimpleGui(Frame):
def browseOpen(self): def browseOpen(self):
filename = tkFileDialog.Open(self, filetypes=[("STL files", ".stl")]).show() filename = tkFileDialog.Open(self, filetypes=[("STL files", ".stl")]).show()
if filename:
self.open(filename)
def open(self, filename):
self.model = None self.model = None
if filename: if filename:
self.InputFileName.set(filename) self.InputFileName.set(filename)
...@@ -206,8 +211,8 @@ class SimpleGui(Frame): ...@@ -206,8 +211,8 @@ class SimpleGui(Frame):
maxx = float(self.MaxX.get())+offset maxx = float(self.MaxX.get())+offset
miny = float(self.MinY.get())-offset miny = float(self.MinY.get())-offset
maxy = float(self.MaxY.get())+offset maxy = float(self.MaxY.get())+offset
minz = float(self.MinZ.get())-offset minz = float(self.MinZ.get())
maxz = float(self.MaxZ.get())+offset maxz = float(self.MaxZ.get())
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())
...@@ -261,12 +266,15 @@ class SimpleGui(Frame): ...@@ -261,12 +266,15 @@ class SimpleGui(Frame):
elif self.Direction.get() == "y": elif self.Direction.get() == "y":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, 0, dz) self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, 0, dz)
elif self.Direction.get() == "xy": elif self.Direction.get() == "xy":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dx, dy, dz) self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dy, dz)
self.ogl.tkRedraw() self.ogl.tkRedraw()
def browseSaveAs(self): def browseSaveAs(self):
filename = tkFileDialog.SaveAs(self, filetypes=[("GCODE files", ".nc .gc .ngc")]).show() filename = tkFileDialog.SaveAs(self, filetypes=[("GCODE files", ".nc .gc .ngc")]).show()
if filename: if filename:
save(self, filename)
def save(self, filename):
self.OutputFileName.set(filename) self.OutputFileName.set(filename)
if self.toolpath: if self.toolpath:
offset = float(self.ToolRadius.get())/2 offset = float(self.ToolRadius.get())/2
......
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