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 os
......@@ -5,5 +6,29 @@ from pycam.Gui.SimpleGui import SimpleGui
from pycam.Importers.TestModel import TestModel
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):
glVertex3f(0,0,size)
glEnd()
if True:
# stock model
minx = float(self.MinX.get())
maxx = float(self.MaxX.get())
......@@ -147,6 +148,10 @@ class SimpleGui(Frame):
def browseOpen(self):
filename = tkFileDialog.Open(self, filetypes=[("STL files", ".stl")]).show()
if filename:
self.open(filename)
def open(self, filename):
self.model = None
if filename:
self.InputFileName.set(filename)
......@@ -206,8 +211,8 @@ class SimpleGui(Frame):
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
minz = float(self.MinZ.get())
maxz = float(self.MaxZ.get())
samples = float(self.Samples.get())
lines = float(self.Lines.get())
layers = float(self.Layers.get())
......@@ -261,12 +266,15 @@ class SimpleGui(Frame):
elif self.Direction.get() == "y":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, 0, dz)
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()
def browseSaveAs(self):
filename = tkFileDialog.SaveAs(self, filetypes=[("GCODE files", ".nc .gc .ngc")]).show()
if filename:
save(self, filename)
def save(self, filename):
self.OutputFileName.set(filename)
if self.toolpath:
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