-------- Original Message --------
Subject: Would someone check my homework
Date: Tue, 18 Dec 2007 21:13:47 -0500
From: Jim Wilkin <[EMAIL PROTECTED]>
To: Enhanced Machine Controller (EMC) <[email protected]>
About a year ago I started working with cnc and emc. With the emc2.2
being able to save
the image to gcode files, I came up with this filter program.
What it does:
When the background is Z = 0 or Z > 0 it removes the XY until Z < 0 .
Saving machine cycle time depending on the shape 25 to 50 percent.
This is my first attempt at python programming so any comments are welcome.
I don't understand common dialog very well and I am hoping some with
more experience
could point out my errors throughout the program.
The program does work but you must be careful not to overwrite files you
want to keep.
Run it in terminal "python zplusfilter.py" .
Happy Holidays Jim
#! /user/bin/python
# Z PLUS FILTER By Jim Wilkin
from Tkinter import *
#from tkMessageBox import *
from tkColorChooser import askcolor
from tkFileDialog import askopenfilename
from tkFileDialog import asksaveasfilename
def callback():
askopenfilename(('gcode')('.ngc'),'r')
def callback2():
asksaveasfilename(mode='w',type=".ngc")
fin = askopenfilename()
fsa = asksaveasfilename()
print fin
print fsa
f = open((fin),"r")
fo = open((fsa),'w')
sfx = ""
sfy = ""
story = ""
storx = ""
x = 0
gd = 0
storexy = ""
storex = ""
storey = ""
sf = 0
go1 =0
while x == 0:
line = f.readline() # read one line
gof = line.find("G1 ") #GO1 code
if gof <> -1 :
line = line[3:(len(line))] #special case when g01 is in x line
go1 = 1 # g01 flag
zf = line.find("Z") #see flags z move
zmf = line.find("Z-") #z- move
fcf = line.find("F") #feed rate
sgf = line.find("G") #g code
ssf = line.find("S") #s code
smf = line.find("M") #m code
spf = line.find("P") #p code
edf = line.find("M2") #m2 finished
cof = line.find("(") #comment
xf = line.find("X") #x move
yf = line.find("Y") #y move
if zf <> -1 or zmf <> -1 or sgf<> -1 or ssf <> -1 or fcf <> -1 or
smf <> spf<> -1 or edf <> -1 or cof <> -1 :
stf = 1 #straight through flag
else:
stf = 0 #store x y flag
if zmf == -1 and xf <> -1 and stf == 0:
storex = ""
storex = storex + line
sfx = 1 #store flags
gd = 1 #got data
if zmf == -1 and yf <> -1 and stf == 0:
storey = ""
storey = storey + line
sfy = 1
gd = 1
if go1 == 1:
go1 = 0
fo.write('G1 ')
print ".",
if stf == 1 and gd == 0:
fo.write(line)
if stf == 1 and gd == 1:
if sfx == 1 and sfy == 1 :
fo.write(storex + storey)
fo.write(line)
gd = 0
elif sfy == 1:
fo.write(story)
fo.write(line)
gd = 0
elif sfx == 1:
fo.write(storex)
fo.write(line)
gd=0
if edf <> -1:
x=11
x = x
f.close()
f.close()
sys.exit(0)
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users