Code:
# The program name is PyNC
import os
import os.path
import time
import math
import re
#======================================================
# Below is a function to make new file folders
#======================================================
def createPath(path):
if not os.path.isdir(path):
os.mkdir(path)
#======================================================
def cls():
os.system(['clear','cls'][os.name == 'nt'])
# use this below, to clear the screen
# cls()
#======================================================
# Search function for user input is directly below
#======================================================
def Userstringsearch(pat, line):
match = re.search (pat, line)
if match: return match.group()
else: return ""
#==============================================================
# Search function to Parse lines is directly below
#==============================================================
def Find(pat, line):
match = re.search (pat, line)
if match: return match.group()
else: return ""
#==============================================================
# variables below are needed to create a blank ncv file
#======================================================
n0 = ' ncv file\n'
n1 = ' Mill depth Z \n'
n2 = ' plunge speed Z \n'
n3 = ' mill speed XY \n'
n4 = ' clear Z \n'
n5 = ' lift Z \n'
n6 = ' rapid down Z \n'
ncvlines = n0+n1+n2+n3+n4+n5+n6
#==========================================================
# These are the lines for the very first 'parsefile' file'
# The program will only parse from this file
#==========================================================
ps0 = """ \n\n\n\nThis is the temporary parse file.
\nWhen the user selects and loads a G-code file from the 'import file' folder,
The contents of that G-code file are copied and then written to here.
\nThe program will only parse code from this file.
\nWhen the program has parsed it's first file, this message will be erased.
"""
#==========================================================
PyNCisthere = ''
importisthere = ''
outputisthere = ''
programisthere = ''
myncvisthere = ''
blankncvisthere = ''
controlncvisthere = ''
parsefileisthere = ''
updatencvisthere = ''
# run a self check before program start
print 'DIR check\n'
time.sleep(0.3)
#=========================================
# find PyNC program folder
if os.path.exists('c:/PyNC'):
PyNCisthere = 1
print "PyNC program folder found"
else:
PyNCisthere = 0
print "PyNC program folder not found"
if PyNCisthere == 0:
createPath("C:\\PyNC")
PyNCisthere = 1
print 'PyNC folder, created'
time.sleep(0.1)
#=========================================
# find import files folder
if os.path.exists('c:/PyNC/import files'):
importisthere = 1
print "\nimport files folder found"
else:
importisthere = 0
print "\nimport files folder not found"
if importisthere == 0:
createPath("C:\\PyNC\\import files")
importisthere = 1
print 'import folder, created'
#=========================================
# find output files folder
if os.path.exists('c:/PyNC/output files'):
outputisthere = 1
print "\noutput files folder found"
else:
outputisthere = 0
print "\noutput files folder not found"
if outputisthere == 0:
createPath("C:\\PyNC\\output files")
outputisthere = 1
print 'output folder, created'
time.sleep(0.1)
#=========================================
# find program files folder
if os.path.exists('c:/PyNC/program files'):
programisthere = 1
print "\nprogram files folder found"
else:
programisthere = 0
print "\nprogram files folder not found"
if programisthere == 0:
createPath("C:\\PyNC\\program files")
programisthere = 1
print 'program folder, created'
time.sleep(0.1)
#=========================================
# find my ncv files folder
if os.path.exists('c:/PyNC/my ncv files'):
myncvisthere = 1
print "\nmy ncv files folder found"
else:
myncvisthere = 0
print "\nmy ncv files folder not found"
if myncvisthere == 0:
createPath("C:\\PyNC\\my ncv files")
myncvisthere = 1
print 'my ncv files folder, created'
#==========================================================
# now check on the important files
print '\nfile check\n'
time.sleep(0.3)
#=========================================
if os.path.exists('c:/PyNC/program files/blankncv.prg'):
blankncvisthere = 1
print "blankncv found"
else:
blankncvisthere = 0
print "blankncv not found"
if blankncvisthere == 0:
fob = open ('c:/PyNC/program files/blankncv.prg','w')
fob.writelines (ncvlines)
fob.close()
blankncvisthere = 1
print 'blankncv file, created'
time.sleep(0.1)
#=========================================
if os.path.exists('c:/PyNC/program files/controlncv.prg'):
controlncvisthere = 1
print "\ncontrolncv found"
else:
controlncvisthere = 0
print "\ncontrolncv not found"
if controlncvisthere == 0:
fob = open ('c:/PyNC/program files/controlncv.prg','w')
fob.writelines (ncvlines)
fob.close()
controlncvisthere = 1
print 'controlncv.prg file, created'
time.sleep(0.1)
#=========================================
if os.path.exists('c:/PyNC/program files/updatencv.prg'):
updatencvisthere = 1
print "\nupdatencv found"
else:
updatencvisthere = 0
print "\nupdatencv not found"
if updatencvisthere == 0:
fob = open ('c:/PyNC/program files/updatencv.prg','w')
fob.writelines (ncvlines)
fob.close()
updatencvisthere = 1
print 'updatencv.prg file, created'
time.sleep(0.1)
#========================================================
if os.path.exists('c:/PyNC/program files/parsefile.prg'):
parsefileisthere = 1
print "\nparsefile found"
else:
parsefileisthere = 0
print "\nparsefile not found"
if parsefileisthere == 0:
fob = open ('c:/PyNC/program files/parsefile.prg','w')
fob.writelines (ps0)
fob.close()
parsefileisthere = 1
print 'parsefile.prg file, created'
time.sleep(0.1)
#=========================================
#============================================================================
# this is the user input instructions
def showchngeInstrctns():
print """\n
=======================================================
============= CHANGE CONFIGURATION ==============
"""
print """
Veiw each configuration, one at a time.\n
You can type any new setting then press Enter.
or,
you can simply press Enter to 'skip' any item you don't
want to change.
When done, you can load the altered settings to the program.
You can create and Name a new .ncv file.
You can overwrite an existing file if you wish to.
"""
#===========================================================================
#===========================================================================
def getzDepth():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
thecontrolncv = fob.readlines()
fob.close()
updatelist1 = (thecontrolncv)
print """=============================================================
======================= Z DEPTH ====================\n"""
print "How deep do you want the Z axis to mill down to ?\n"
print "\nThe current Z depth is... ", updatelist1[1]
print """\nIf you just press Enter to skip,
the current Z depth will remain.
"""
print "Be certain to use a minus for anything below 0(the surface)\n"
userzdepth = raw_input("enter a depth, for Z to mill into the surface :")
nn1 = ' Mill depth Z '
newline = "\n"
if userzdepth != "\n":
consolein1 = Userstringsearch( r' *-*\.*\d\d*\.*\d* *', userzdepth )
if consolein1 != "":
string1 = (consolein1)
string1strip = (string1).strip() # strip any white space here
if string1strip.isdigit:
zdepth = (string1strip)
updatelist[1] = nn1 + zdepth + newline
print updatelist[1]
return updatelist[1]
else:
pass
#============================================================================
#=============================================================================
def getzplungeSpeed():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
thecontrolgcf = fob.readlines()
fob.close()
updatelist1 = (thecontrolgcf)
print """=============================================================
==================== Z PLUNGE SPEED =================\n"""
print "What speed should Z enter the material ?"
print "\nThe current Z plunge speed is... ", updatelist1[2]
print """\nIf you just press Enter to skip,
the current Z plunge speed will remain.
"""
userzplunge = raw_input("enter a speed that Z will enter the material :")
nn2 = ' plunge speed Z '
newline = "\n"
if userzplunge != "\n":
consolein1 = Userstringsearch( r' *\.*\d\d*\.*\d* *', userzplunge )
if consolein1 != "":
string1 = (consolein1)
string1strip = (string1).strip() # strip any white space here
if string1strip.isdigit:
zplunge = (string1strip)
updatelist[2] = nn2 + zplunge + newline
print updatelist[2]
return updatelist[2]
else:
pass
#=============================================================================
#=============================================================================
def getxymillSpeed():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
thecontrolgcf = fob.readlines()
fob.close()
updatelist1 = (thecontrolgcf)
print """=============================================================
==================== MILLING SPEED =================\n"""
print "What speed, do want XY to mill the material ?"
print "\nThe current milling speed is... ", updatelist1[3]
print """\nIf you just press Enter to skip,
the current milling speed will remain.
"""
userxymill = raw_input("enter a speed for XY to mill the material :")
nn3 = ' mill speed XY '
newline = "\n"
if userxymill != "\n":
consolein1 = Userstringsearch( r' *\.*\d\d*\.*\d* *', userxymill )
if consolein1 != "":
string1 = (consolein1)
string1strip = (string1).strip() # strip any white space here
if string1strip.isdigit:
xymill = (string1strip)
updatelist[3] = nn3 + xymill + newline
print updatelist[3]
return updatelist[3]
else:
pass
#=============================================================================
#=============================================================================
def getzClear():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
thecontrolgcf = fob.readlines()
fob.close()
updatelist1 = (thecontrolgcf)
print """=============================================================
================= Z CLEARANCE HEIGHT ===============\n"""
print "You can clear clamps and fixtures when starting or going home."
print "\nHow high do you want Z to lift clear ?"
print "\nThe current Z clearance height is... ", updatelist1[4]
print """\nIf you just press Enter to skip,
the current Z clearance height will remain.
"""
userzclear = raw_input("enter a coordinate for Z to clear any fixtures :")
nn4 = ' clear Z '
newline = "\n"
if userzclear != "\n":
consolein1 = Userstringsearch( r' *\.*\d\d*\.*\d* *', userzclear )
if consolein1 != "":
string1 = (consolein1)
string1strip = (string1).strip() # strip any white space here
if string1strip.isdigit:
zclearance = (string1strip)
updatelist[4] = nn4 + zclearance + newline
print updatelist[4]
return updatelist[4]
else:
pass
#=============================================================================
#=============================================================================
def getnormalzLift():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
thecontrolgcf = fob.readlines()
fob.close()
updatelist1 = (thecontrolgcf)
print """=============================================================
================= NORMAL Z HEIGHT ===============\n"""
print "How high do you want Z to lift normally during a job run ?"
print "\nThe current Z lift height is... ", updatelist1[5]
print """\nIf you just press Enter to skip,
the current normal Z lift height will remain.
"""
userzlift = raw_input("enter a coordinate for Z to lift normally :")
nn5 = ' lift Z '
newline = "\n"
if userzlift != "\n":
consolein1 = Userstringsearch( r' *\.*\d\d*\.*\d* *', userzlift )
if consolein1 != "":
string1 = (consolein1)
string1strip = (string1).strip() # strip any white space here
if string1strip.isdigit:
zliftnorm = (string1strip)
updatelist[5] = nn5 + zliftnorm + newline
print updatelist[5]
return updatelist[5]
else:
pass
#=============================================================================
#=============================================================================
def getminzrapiDown():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
thecontrolgcf = fob.readlines()
fob.close()
updatelist1 = (thecontrolgcf)
print """=============================================================
================== Z RAPID DOWN ================\n"""
print "To save time, the Z axis can rapid move to a minimum height,"
print "above the material surface."
print "\nThe current Z rapid down height is... ", updatelist1[6]
print """\nIf you just press Enter to skip,
the current mimimum Z rapid down, will remain.
"""
userzminrapid = raw_input("enter a height for Z to rapid down to :")
nn6 = ' rapid down Z '
newline = "\n"
if userzminrapid != "\n":
consolein1 = Userstringsearch( r' *\.*\d\d*\.*\d* *', userzminrapid )
if consolein1 != "":
string1 = (consolein1)
string1strip = (string1).strip() # strip any white space here
if string1strip.isdigit:
zminrapid = (string1strip)
updatelist[6] = nn6 + zminrapid + newline
print updatelist[6]
return updatelist[6]
else:
pass
#=============================================================================
#=============================================================================
# this is the 'question the user' function
# call userinPut() from one of the menu items at main().
def userinPut():
Openupdatencv()
cls()
showchngeInstrctns()
tocontinue = raw_input("Press enter to continue... :")
# Questions start from here
cls()
getzDepth()
time.sleep(1)
cls()
getzplungeSpeed()
time.sleep(1)
cls()
getxymillSpeed()
time.sleep(1)
cls()
getzClear()
time.sleep(1)
cls()
getnormalzLift()
time.sleep(1)
cls()
getminzrapiDown()
time.sleep(1)
cls()
print """
==================================================================
===================== ! ! S T O P ! ! =====================
===================== you can =====================
===================== L O A D =====================
===================== S E T T I N G S =====================
===================== and =====================
===================== create a new =====================
===================== ncv file =====================
===================== if you wish =====================
==================================================================
"""
print """
If you have changed any settings,
You will be able to 'Load' these settings,
The program would then use these to process the next G-code file.
If you don't 'Load' settings,
the program will continue to use it's last loaded settings.
You will also be asked, if you want to 'Name' a new ncv file.
You can overwite an existing file.
These 2 actions won't 'load' any new settings.
You can just skip each one and don't do anything.
"""
loadsettings = raw_input("""\n\nTo Load settings, Enter Y for yes,
or just press Enter to skip loading ... :""")
if loadsettings == "Y" or loadsettings == "y":
with open('c:/PyNC/program files/updatencv.prg','w') as fob:
fob.writelines (updatelist)
fob.close()
with open('c:/PyNC/program files/controlncv.prg','w') as fob:
fob.writelines (updatelist)
fob.close()
print "\n\nDone"
time.sleep(1)
cls()
namemyNcv()
#=============================================================================
# this is for naming a ncv file
def namemyNcv():
successful = 0
while successful == 0:
cls()
answer = raw_input("""
Go ahead and Type a Name for your ncv file then press Enter...
OR you can,
just press Enter only, to skip this.... :""")
answerstring = str(answer) # make sure the answer is now a string
answerstrip = (answerstring).strip()# strip any white space here
newfile = (answerstrip) # this is the answer as a string
extension = '.ncv'
thename = 'No name.ncv'
answername = newfile + extension
answername1 = str(answername)
long_file_name = answername1
filetest = os.path.exists('c:/PyNC/my ncv files/'+ answername1)
if filetest == True:
if answername1=='.ncv':
file = open('c:/PyNC/my ncv files/'+ thename ,'w')
file.writelines(updatelist)
file.close()
answername1 = thename
long_file_name = answername1
successful = 1
cls()
print "\n\n\nJust in case, PyNC has auto-saved the file as... "+ long_file_name
getout = raw_input("\n Press Enter to leave Naming... :")
break
if filetest == False:
if answername1=='.ncv':
file = open('c:/PyNC/my ncv files/'+ thename ,'w')
file.writelines(updatelist)
file.close()
answername1 = thename
long_file_name = answername1
successful = 1
cls()
print "\n\n\nJust in case, PyNC has auto-saved the file as... "+ long_file_name
getout = raw_input("\n Press Enter to leave Naming... :")
break
if filetest == False:
if answer!= '\n':
file = open('c:/PyNC/my ncv files/'+ long_file_name ,'w')
file.writelines(updatelist)
file.close()
cls()
print "\n\n\nYou're new file named... "+long_file_name +" has been saved"
successful = 1
getout = raw_input("\n Press Enter to leave Naming... :")
break
# #
if filetest == True:
if answer!= '\n':
cls()
print """
There's already a file called... """ +long_file_name + """
You can over-write this file if you want to.
Type Y for yes .... or N for no.
"""
yesno = raw_input("\ntype Y or N .. then Enter, here... :")
if yesno == "Y" or yesno == "y":
file = open('c:/PyNC/my ncv files/'+ long_file_name ,'w')
file.writelines(updatelist)
file.close()
cls()
print """
The existing file called.. """+ long_file_name + """
has been over-written"""
getout = raw_input("\nPress Enter to leave Naming... :")
successful = 1
break
elif yesno == "N" or yesno == "n":
cls()
print """
The existing file called.. """+ long_file_name + """
won't be over-written"""
moveon = raw_input("""
Press Enter and try again ... :""")
long_file_name = 'No name.ncv'
successful = 0
pass
# #
else:
successful = 0
#=============================================================================
# This function enumerates a list of the files found in 'my ncv files',
# then prints to screen for the user to select and load 1 file.
def getncvList():
print """
======================================================================
================= THIS IS THE *.ncv FILE LIST ====================
"""
ncvlist = os.listdir('c:\\PyNC\\my ncv files')
itemsindir = len(ncvlist)
if itemsindir == 0:
print 'there are no files in my ncv files folder'
time.sleep(2)
elif itemsindir >0:
print 0,ncvlist[0]
for i in xrange(1,len(ncvlist)):
c=ncvlist[i]
print i,c
#=============================================================================
# This loads the settings from the file, then displays controlncv.prg.
def userncvChoice():
print"""
======================================================================
You can just press Enter if you decide not to load a ncv file
"""
ncvlist = os.listdir('c:\\PyNC\\my ncv files')
itemsindir = len(ncvlist)
if itemsindir == 0:
pass
elif itemsindir >0:
userchoice = raw_input("select a file to load, by it's number, then press Enter.. :")
if userchoice.isdigit():
number = int(userchoice) # choice is now a real number
thename = ncvlist[number] # this has selected file's name as a str
filename = str(thename)
choice = filename
with open('c:/PyNC/my ncv files/'+ choice ,'r') as fob:
loaded = fob.readlines()
fob.close()
with open('c:/PyNC/my ncv files/'+ choice ,'r') as f:
read_data = f.read()
f.close
b = read_data
cls()
print """
You've just loaded the new settings from a ncv;
If you loaded the wrong file, you'll have to exit here, then,
come back from the Main Menu to load a different file.
Below, are the values you loaded.
"""
with open('c:/PyNC/program files/controlncv.prg','w') as fob:
fob.writelines (loaded)
fob.close()
with open('c:/PyNC/program files/updatencv.prg','w') as fob:
fob.writelines (loaded)
fob.close()
print b
else:
pass
#=============================================================================
# This function enumerates a list of the files in the 'import files folder',
# then prints this to screen for the user to select and load 1 file.
def getimportList():
print """
======================================================================
================ THIS IS THE IMPORT FILE LIST ====================
The list below is 'enumerated', so the first number on each line,
is a file selection number.
----------------------------------------------------------------------"""
ncvlist = os.listdir('c:\\PyNC\\import files')
itemsindir = len(ncvlist)
if itemsindir == 0:
print 'there are no files in the import files folder'
time.sleep(2)
elif itemsindir >0:
print 0,ncvlist[0]
for i in xrange(1,len(ncvlist)):
c=ncvlist[i]
print i,c
#=============================================================================
#=============================================================================
# This loads the import file, then displays contents of controlgcf.prg.
def userimportChoice():
print"""
======================================================================
You can just press Enter if you decide not to import a file
"""
ncvlist = os.listdir('c:\\PyNC\\import files')
itemsindir = len(ncvlist)
if itemsindir == 0:
pass
elif itemsindir >0:
userchoice = raw_input("select a file to import, by it's number, then press Enter.. :")
if userchoice.isdigit():
number = int(userchoice) # choice is now a real number
thename = ncvlist[number] # this has selected the file's name as a str
filename = str(thename)
choice = filename
with open('c:/PyNC/import files/'+ choice ,'r') as f:
read_data = f.read()
f.close
b = read_data
cls()
loaded = b
print """\n\n\n\n\n
the file selected is loaded;\n\n\n
If you've imported the wrong file, continue to exit from here,\n
then you can come back from the Main Menu and load another file.\n\n\n
"""
time.sleep(4)
with open('c:/PyNC/program files/parsefile.prg','w') as fob:
fob.writelines (loaded)
fob.close()
else:
pass
#=============================================================================
#=============================================================================
#=============================================================================
#=============================================================================
def theParse():
cls()
#=========================================================
# this section below, is to gather all control values for the parse
# from the controlncv.prg file
# #=========================================================
def ncvzDepth():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
getcontrolvalues = fob.readlines()
fob.close()
thecontrolncvlist = (getcontrolvalues)
thencvlist = thecontrolncvlist[1] # = usermill depth
line = "".join (thencvlist)
dsearch = Find( r' *-*\.*\d\d*\.*\d* *', line)
if dsearch != "":
dstring = (dsearch)
dstrip = (dstring).strip() # strip the white space here
list (dstrip) # the list(zstrip) has no white space
dword = list (dstring)
if dword [0] .isdigit or dword [1].isdigit: # check if 1st or 2nd in list is digit
dlistnum = dword [1: ]
dstringnum = "".join (dlistnum)
dnum = (dstringnum).strip() # strip white space from numbers
d = float (dnum)
return d
else:
d = " "
return d
#==============================================================
def ncvPlunge():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
getcontrolvalues = fob.readlines()
fob.close()
thecontrolncvlist = (getcontrolvalues)
thencvlist = thecontrolncvlist[2]
line = "".join (thencvlist)
dsearch = Find( r' *-*\.*\d\d*\.*\d* *', line)
if dsearch != "":
dstring = (dsearch)
dstrip = (dstring).strip()
list (dstrip)
dword = list (dstring)
if dword [0] .isdigit or dword [1].isdigit:
dlistnum = dword [1: ]
dstringnum = "".join (dlistnum)
dnum = (dstringnum).strip()
d = float (dnum)
return d
else:
d = " "
return d
#==============================================================
def ncvMill():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
getcontrolvalues = fob.readlines()
fob.close()
thecontrolncvlist = (getcontrolvalues)
thencvlist = thecontrolncvlist[3]
line = "".join (thencvlist)
dsearch = Find( r' *-*\.*\d\d*\.*\d* *', line)
if dsearch != "":
dstring = (dsearch)
dstrip = (dstring).strip()
list (dstrip)
dword = list (dstring)
if dword [0] .isdigit or dword [1].isdigit:
dlistnum = dword [1: ]
dstringnum = "".join (dlistnum)
dnum = (dstringnum).strip()
d = float (dnum)
return d
else:
d = " "
return d
#==============================================================
#==============================================================
def ncvzClear():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
getcontrolvalues = fob.readlines()
fob.close()
thecontrolncvlist = (getcontrolvalues)
thencvlist = thecontrolncvlist[4]
line = "".join (thencvlist)
dsearch = Find( r' *-*\.*\d\d*\.*\d* *', line)
if dsearch != "":
dstring = (dsearch)
dstrip = (dstring).strip()
list (dstrip)
dword = list (dstring)
if dword [0] .isdigit or dword [1].isdigit:
dlistnum = dword [1: ]
dstringnum = "".join (dlistnum)
dnum = (dstringnum).strip()
d = float (dnum)
return d
else:
d = " "
return d
#==============================================================
#==============================================================
def ncvzLift():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
getcontrolvalues = fob.readlines()
fob.close()
thecontrolncvlist = (getcontrolvalues)
thencvlist = thecontrolncvlist[5]
line = "".join (thencvlist)
dsearch = Find( r' *-*\.*\d\d*\.*\d* *', line)
if dsearch != "":
dstring = (dsearch)
dstrip = (dstring).strip()
list (dstrip)
dword = list (dstring)
if dword [0] .isdigit or dword [1].isdigit:
dlistnum = dword [1: ]
dstringnum = "".join (dlistnum)
dnum = (dstringnum).strip()
d = float (dnum)
return d
else:
d = " "
return d
#==============================================================
#==============================================================
def ncvrapiDown():
with open('c:/PyNC/program files/controlncv.prg','r') as fob:
getcontrolvalues = fob.readlines()
fob.close()
thecontrolncvlist = (getcontrolvalues)
thencvlist = thecontrolncvlist[6]
line = "".join (thencvlist)
dsearch = Find( r' *-*\.*\d\d*\.*\d* *', line)
if dsearch != "":
dstring = (dsearch)
dstrip = (dstring).strip()
list (dstrip)
dword = list (dstring)
if dword [0] .isdigit or dword [1].isdigit:
dlistnum = dword [1: ]
dstringnum = "".join (dlistnum)
dnum = (dstringnum).strip()
d = float (dnum)
return d
else:
d = " "
return d
#==============================================================
zdepth = ncvzDepth()
plunge = ncvPlunge()
mill = ncvMill()
zclear = ncvzClear()
zheight = ncvzLift()
zdownmin = ncvrapiDown()
#========================
if zdepth == ' ':
print 'No Z milling depth found.'
else:
print zdepth
#========================
if plunge == ' ':
print 'No Z plunge speed found.'
else:
print plunge
#========================
if mill == ' ':
print 'No X,Y milling speed found.'
else:
print mill
#========================
if zclear == ' ':
print 'No Z fixture clearance height found.'
else:
print zclear
#========================
if zheight == ' ':
print 'No Z normal lift height found.'
else:
print zheight
#========================
if zdownmin == ' ':
print 'No minimum Z rapid down height found'
else:
print zdownmin
#========================
print """
Above, all ncv values are extracted if they are present
in the controlncv.prg file.
This area is reserved for 'theParse'.
The 'engine' of the program will go here.
It will be twice as large as the entire program so far.
Where;
All ncv values are extracted.
All code line searches are done.
All code words and values are extracted.
All code word arguments will occur.
All output lines are assembled.
The output file is written to.
"""
#=============================================================================
#=============================================================================
#=============================================================================
#=============================================================================
def show_instructions():
print """\n
=======================================================
========= THIS IS THE MAIN PROGRAM MENU =========\n
Select a process number, then Press Enter, to run it.
"""
print " 0: Exit the program\n"
print " 1: Import a G-code file\n"
print " 2: Process the G-code file\n"
print " 3: Check the current settings\n"
print """ 4: 'Create' a new .ncv file or,
'Change' any or all
"""
print " 5: load new config settings from any ncv file\n"
#=============================================================================
# This opens and prints to screen all the current config settings.
def view():
with open('c:/PyNC/program files/updatencv.prg','r') as f:
read_data = f.read()
f.close()
a = read_data
print a
#=============================================================================
# This opens the updatencv.prg file and creates the update list
def Openupdatencv():
with open('c:/PyNC/program files/updatencv.prg','r') as fob:
updatencv = fob.readlines()
fob.close()
updatelist = (updatencv)
return updatelist
updatelist = Openupdatencv()
#=============================================================================
# main function loop that brings it all together
def main():
selection = None
while selection != "0":
cls()
show_instructions()
selection = raw_input ("\n\nType in an Item number, then Enter, to run it:")
#=============================================================================
if selection == "1":
cls()
getimportList()
userimportChoice()
goback = raw_input ('\n\nPress enter .... Return to Main Menu:')
if goback == "\n":
pass
#=============================================================================
elif selection == "2":
cls()
theParse()
goback = raw_input ('\n\nPress enter .... Return to Main Menu:')
if goback == "\n":
pass
#=============================================================================
elif selection == "3":
cls()
print """\n
========= THESE ARE THE CURRENT MACHINE SETTINGS =========\n\n"""
view()
goback = raw_input ('\n\nPress enter .... Return to Main Menu:')
if goback == "\n":
pass
#=============================================================================
elif selection == "4":
cls()
print """\n
===================== CHANGE SETTINGS ======================\n\n"""
userinPut()
goback = raw_input ('\n\nPress enter .... Return to Main Menu:')
if goback == "\n":
pass
#=============================================================================
elif selection == "5":
cls()
print """\n
=================== LOAD NEW SETTINGS =====================\n\n"""
cls()
getncvList()
userncvChoice()
goback = raw_input ('\n\nPress enter .... Return to Main Menu:')
if goback == "\n":
pass
#=============================================================================
print "Program closing."
time.sleep(1)
main()
#=============================================================================