G-Code Generator
22 Aug 2015 02:03 #61631
by mmt
G-Code Generator was created by mmt
i have built a G-Code generator in PY. It works just like I need it to, however the only change i would like to make is to be able to send the program to Axis and the PY window remain open. I used most of the g-code generators in the wiki to help me write the code but every one of them sends the program to axis and then closes the py window.
I have a lot of boxes for my operators to fill in and now if they want to change just one thing they have to reopen py and start all over with entries.
If someone has a sample program that you could post here I would really appreciate it.
Thanks
kent
I have a lot of boxes for my operators to fill in and now if they want to change just one thing they have to reopen py and start all over with entries.
If someone has a sample program that you could post here I would really appreciate it.
Thanks
kent
Please Log in or Create an account to join the conversation.
22 Aug 2015 13:06 #61641
by ArcEye
Replied by ArcEye on topic G-Code Generator
Hi
You can do what you want by simply using axis-remote.
os.system("axis-remote filename")
from inside your code will load the named file, so long as linuxcnc is running, not executing a command at the time and using the Axis GUI.
regards
You can do what you want by simply using axis-remote.
os.system("axis-remote filename")
from inside your code will load the named file, so long as linuxcnc is running, not executing a command at the time and using the Axis GUI.
regards
Please Log in or Create an account to join the conversation.
22 Aug 2015 17:29 - 22 Aug 2015 18:48 #61645
by BigJohnT
Replied by BigJohnT on topic G-Code Generator
If you run the attached config you will get a G code generator that launches with Axis and stays open after sending the file to Axis.
Did you get my reply to your email?
JT
Did you get my reply to your email?
JT
Last edit: 22 Aug 2015 18:48 by BigJohnT.
Please Log in or Create an account to join the conversation.
25 Aug 2015 01:49 #61748
by mmt
Replied by mmt on topic G-Code Generator
I didn't get it John but this thread is the question I wanted to ask you.
i will let you know if this works.....
Thank you Thank you
i will let you know if this works.....
Thank you Thank you
Please Log in or Create an account to join the conversation.
25 Aug 2015 02:21 #61750
by mmt
Replied by mmt on topic G-Code Generator
Ok John which file are you referring to? I don't see a config file
Please Log in or Create an account to join the conversation.
25 Aug 2015 02:34 #61751
by BigJohnT
Replied by BigJohnT on topic G-Code Generator
The one I attached in the previous message.
JT
JT
Please Log in or Create an account to join the conversation.
25 Aug 2015 22:49 #61787
by mmt
Replied by mmt on topic G-Code Generator
Sorry John I should have been more specific.
I opened your setup with axis and didn't get a python window
I opened your setup with axis and didn't get a python window
Please Log in or Create an account to join the conversation.
26 Aug 2015 01:09 #61789
by mmt
Replied by mmt on topic G-Code Generator
Ok been working on this for a few hours and I am clueless.
Arceye or BigJohn could you look at my file and give me some assistance.
My buttons are lines 403-438
Arceye or BigJohn could you look at my file and give me some assistance.
My buttons are lines 403-438
Please Log in or Create an account to join the conversation.
26 Aug 2015 01:12 #61790
by mmt
Replied by mmt on topic G-Code Generator
I can't get it to attach ???
Please Log in or Create an account to join the conversation.
26 Aug 2015 01:13 - 26 Aug 2015 18:54 #61791
by mmt
Replied by mmt on topic G-Code Generator
#!/usr/bin/python
from Tkinter import *
from math import *
import sys, os
import tkMessageBox
IN_AXIS = os.environ.has_key("AXIS_PROGRESS_BAR")
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.createWidgets()
self.DoIt()
def createWidgets(self):
self.CanvasDrawings = []
self.gcode = []
self.PreviewFrame = Frame(self, bd=3)
self.PreviewFrame.grid(row=14, column=1)
self.PreviewCanvas = Canvas(self.PreviewFrame, width=300, height=300, bg='white', bd='3', relief='raised')
self.PreviewCanvas.grid(sticky=N + S + E + W)
self.segID = []
self.EntryFrame = Frame(self, bd=5)
self.EntryFrame.grid(row=0, column=1)
# Activate Column
self.st0 = Label(self.EntryFrame, text='Activate', width=10, font="-weight bold")
self.st0.grid(row=0, column=0, columnspan=1)
self.FrontOn = IntVar()
self.FrontOn.set(1)
Checkbutton(self.EntryFrame, text='Front', variable=self.FrontOn, onvalue=1, offvalue=0,
command=self.DoIt).grid(row=1, column=0, sticky=W)
self.ReductionOn = IntVar()
self.ReductionOn.set(1)
Checkbutton(self.EntryFrame, text='Reduction', variable=self.ReductionOn, onvalue=1, offvalue=0,
command=self.DoIt).grid(row=2, column=0, sticky=W)
self.BearingOn = IntVar()
self.BearingOn.set(1)
Checkbutton(self.EntryFrame, text='Bearing', variable=self.BearingOn, onvalue=1, offvalue=0,
command=self.DoIt).grid(row=3, column=0, sticky=W)
self.BackOn = IntVar()
self.BackOn.set(1)
Checkbutton(self.EntryFrame, text='Back', variable=self.BackOn, onvalue=1, offvalue=0, command=self.DoIt).grid(
row=4, column=0, sticky=W)
self.ProbeOn = IntVar()
self.ProbeOn.set(1)
Checkbutton(self.EntryFrame, text='Probe ', variable=self.ProbeOn, onvalue=1, offvalue=0,
command=self.DoIt).grid(row=5, column=0, sticky=W)
# Strategy Column
self.st1 = Label(self.EntryFrame, text='Strategy', width=10, font="-weight bold")
self.st1.grid(row=0, column=1, columnspan=1)
self.st2 = Label(self.EntryFrame, text='Steps', width=10)
self.st2.grid(row=2, column=1, columnspan=1)
self.st3 = Label(self.EntryFrame, text='Steps', width=10)
self.st3.grid(row=3, column=1, columnspan=1)
# Current Column
self.st4 = Label(self.EntryFrame, text='Current', width=10, font="-weight bold")
self.st4.grid(row=0, column=2, columnspan=1)
self.EntranceCurrent = StringVar()
self.EntranceCurrent.set('12')
self.ECurrent = Entry(self.EntryFrame, textvariable=self.EntranceCurrent, width=5)
self.ECurrent.grid(row=1, column=2)
self.ReductionCurrent = StringVar()
self.ReductionCurrent.set('12.5')
self.RCurrent = Entry(self.EntryFrame, textvariable=self.ReductionCurrent, width=5)
self.RCurrent.grid(row=2, column=2)
self.BearingCurrent = StringVar()
self.BearingCurrent.set('12.75')
self.BCurrent = Entry(self.EntryFrame, textvariable=self.BearingCurrent, width=5)
self.BCurrent.grid(row=3, column=2)
self.BackCurrent = StringVar()
self.BackCurrent.set('12')
self.BaCurrent = Entry(self.EntryFrame, textvariable=self.BackCurrent, width=5)
self.BaCurrent.grid(row=4, column=2)
# Q-Switch Column
self.st5 = Label(self.EntryFrame, text='Q-Switch', width=10, font="-weight bold")
self.st5.grid(row=0, column=3, columnspan=1)
self.EntranceQSwitch = StringVar()
self.EntranceQSwitch.set('2500')
self.EQSwitch = Entry(self.EntryFrame, textvariable=self.EntranceQSwitch, width=5)
self.EQSwitch.grid(row=1, column=3)
self.ReductionQSwitch = StringVar()
self.ReductionQSwitch.set('2500')
self.RQSwitch = Entry(self.EntryFrame, textvariable=self.ReductionQSwitch, width=5)
self.RQSwitch.grid(row=2, column=3)
self.BearingQSwitch = StringVar()
self.BearingQSwitch.set('2500')
self.BQSwitch = Entry(self.EntryFrame, textvariable=self.BearingQSwitch, width=5)
self.BQSwitch.grid(row=3, column=3)
self.BackQSwitch = StringVar()
self.BackQSwitch.set('2500')
self.BaQSwitch = Entry(self.EntryFrame, textvariable=self.BackQSwitch, width=5)
self.BaQSwitch.grid(row=4, column=3)
# Speed Column
self.st6 = Label(self.EntryFrame, text='Speed', width=10, font="-weight bold")
self.st6.grid(row=0, column=4, columnspan=1)
self.EntranceSpeed = StringVar()
self.EntranceSpeed.set('900')
self.ESpeed = Entry(self.EntryFrame, textvariable=self.EntranceSpeed, width=5)
self.ESpeed.grid(row=1, column=4)
self.ReductionSpeed = StringVar()
self.ReductionSpeed.set('900')
self.RSpeed = Entry(self.EntryFrame, textvariable=self.ReductionSpeed, width=5)
self.RSpeed.grid(row=2, column=4)
self.BearingSpeed = StringVar()
self.BearingSpeed.set('900')
self.BSpeed = Entry(self.EntryFrame, textvariable=self.BearingSpeed, width=5)
self.BSpeed.grid(row=3, column=4)
self.BackSpeed = StringVar()
self.BackSpeed.set('900')
self.BaSpeed = Entry(self.EntryFrame, textvariable=self.BackSpeed, width=5)
self.BaSpeed.grid(row=4, column=4)
# Steps Column
self.st7 = Label(self.EntryFrame, text='Steps', width=10, font="-weight bold")
self.st7.grid(row=0, column=5, columnspan=1)
self.EntranceSteps = StringVar()
self.EntranceSteps.set('.001')
self.ESteps = Entry(self.EntryFrame, textvariable=self.EntranceSteps, width=5)
self.ESteps.grid(row=1, column=5)
self.ReductionSteps = StringVar()
self.ReductionSteps.set('.001')
self.RSteps = Entry(self.EntryFrame, textvariable=self.ReductionSteps, width=5)
self.RSteps.grid(row=2, column=5)
self.BearingSteps = StringVar()
self.BearingSteps.set('.001')
self.BSteps = Entry(self.EntryFrame, textvariable=self.BearingSteps, width=5)
self.BSteps.grid(row=3, column=5)
self.BackSteps = StringVar()
self.BackSteps.set('.001')
self.BaSteps = Entry(self.EntryFrame, textvariable=self.BackSteps, width=5)
self.BaSteps.grid(row=4, column=5)
# Feed Column
self.st8 = Label(self.EntryFrame, text='Feed', width=10, font="-weight bold")
self.st8.grid(row=0, column=6, columnspan=1)
self.EntranceFeed = StringVar()
self.EntranceFeed.set('.15')
self.EFeed = Entry(self.EntryFrame, textvariable=self.EntranceFeed, width=5)
self.EFeed.grid(row=1, column=6)
self.ReductionFeed = StringVar()
self.ReductionFeed.set('.15')
self.RFeed = Entry(self.EntryFrame, textvariable=self.ReductionFeed, width=5)
self.RFeed.grid(row=2, column=6)
self.BearingFeed = StringVar()
self.BearingFeed.set('.15')
self.BFeed = Entry(self.EntryFrame, textvariable=self.BearingFeed, width=5)
self.BFeed.grid(row=3, column=6)
self.BackFeed = StringVar()
self.BackFeed.set('.15')
self.BaFeed = Entry(self.EntryFrame, textvariable=self.BackFeed, width=5)
self.BaFeed.grid(row=4, column=6)
# Focal Column
self.st9 = Label(self.EntryFrame, text='Focal', width=10, font="-weight bold")
self.st9.grid(row=0, column=7, columnspan=1)
self.EntranceFocal = StringVar()
self.EntranceFocal.set('0')
self.EFocal = Entry(self.EntryFrame, textvariable=self.EntranceFocal, width=5)
self.EFocal.grid(row=1, column=7)
self.ReductionFocal = StringVar()
self.ReductionFocal.set('0')
self.RFocal = Entry(self.EntryFrame, textvariable=self.ReductionFocal, width=5)
self.RFocal.grid(row=2, column=7)
self.BearingFocal = StringVar()
self.BearingFocal.set('0')
self.BFocal = Entry(self.EntryFrame, textvariable=self.BearingFocal, width=5)
self.BFocal.grid(row=3, column=7)
self.BackFocal = StringVar()
self.BackFocal.set('0')
self.BaFocal = Entry(self.EntryFrame, textvariable=self.BackFocal, width=5)
self.BaFocal.grid(row=4, column=7)
# Over-Run Column
self.st10 = Label(self.EntryFrame, text='Over-Run', width=10, font="-weight bold")
self.st10.grid(row=0, column=8, columnspan=1)
self.EntranceOverrun = StringVar()
self.EntranceOverrun.set('0')
self.EOverrun = Entry(self.EntryFrame, textvariable=self.EntranceOverrun, width=5)
self.EOverrun.grid(row=1, column=8)
self.ReductionOverrun = StringVar()
self.ReductionOverrun.set('0')
self.ROverrun = Entry(self.EntryFrame, textvariable=self.ReductionOverrun, width=5)
self.ROverrun.grid(row=2, column=8)
self.BearingOverrun = StringVar()
self.BearingOverrun.set('0')
self.BOverrun = Entry(self.EntryFrame, textvariable=self.BearingOverrun, width=5)
self.BOverrun.grid(row=3, column=8)
self.BackOverrun = StringVar()
self.BackOverrun.set('0')
self.BaOverrun = Entry(self.EntryFrame, textvariable=self.BackOverrun, width=5)
self.BaOverrun.grid(row=4, column=8)
# Aperature Column
self.st11 = Label(self.EntryFrame, text='Aperature', width=10, font="-weight bold")
self.st11.grid(row=0, column=9, columnspan=1)
self.EntanceAp= IntVar()
self.EntanceAp.set(0)
Checkbutton(self.EntryFrame, variable=self.EntanceAp, onvalue=1, offvalue=0, command=self.DoIt).grid(row=1,
column=9,
sticky=W)
self.ReductionAp = IntVar()
self.ReductionAp.set(0)
Checkbutton(self.EntryFrame, variable=self.ReductionAp, onvalue=1, offvalue=0, command=self.DoIt).grid(row=2,
column=9,
sticky=W)
self.BearingAp = IntVar()
self.BearingAp.set(0)
Checkbutton(self.EntryFrame, variable=self.BearingAp, onvalue=1, offvalue=0, command=self.DoIt).grid(row=3,
column=9,
sticky=W)
self.BackAp = IntVar()
self.BackAp.set(0)
Checkbutton(self.EntryFrame, variable=self.BackAp, onvalue=1, offvalue=0, command=self.DoIt).grid(row=4,
column=9,
sticky=W)
# Space
self.st12 = Label(self.EntryFrame, text=' ', width=10)
self.st12.grid(row=9, column=0, columnspan=1)
# Probe X Position
self.st13 = Label(self.EntryFrame, text='Probe X', width=10)
self.st13.grid(row=10, column=0, columnspan=1)
self.XProbe = StringVar()
self.XProbe.set('.985')
self.XPPosition = Entry(self.EntryFrame, textvariable=self.XProbe, width=5)
self.XPPosition.grid(row=10, column=1)
# Probe Y Position
self.st14 = Label(self.EntryFrame, text='Probe Y', width=10)
self.st14.grid(row=11, column=0, columnspan=1)
self.YProbe = StringVar()
self.YProbe.set('-2.645')
self.YPPosition = Entry(self.EntryFrame, textvariable=self.YProbe, width=5)
self.YPPosition.grid(row=11, column=1)
# Probe Z Position
self.st15 = Label(self.EntryFrame, text='Probe Z', width=10)
self.st15.grid(row=12, column=0, columnspan=1)
self.ZProbe = StringVar()
self.ZProbe.set('-.377')
self.ZPPosition = Entry(self.EntryFrame, textvariable=self.ZProbe, width=5)
self.ZPPosition.grid(row=12, column=1)
# Nib Thickness
self.st16 = Label(self.EntryFrame, text='Nib Thickness', width=10)
self.st16.grid(row=7, column=0, columnspan=1)
self.NibThickness = StringVar()
self.NibThickness.set('.059')
self.NThickness = Entry(self.EntryFrame, textvariable=self.NibThickness, width=5)
self.NThickness.grid(row=7, column=1)
# Gap
self.st17 = Label(self.EntryFrame, text='Gap', width=10)
self.st17.grid(row=8, column=0, columnspan=1)
self.Gap = StringVar()
self.Gap.set('0')
self.G = Entry(self.EntryFrame, textvariable=self.Gap, width=5)
self.G.grid(row=8, column=1)
# Front Info
self.st18 = Label(self.EntryFrame, text='Front', width=10, font="-weight bold")
self.st18.grid(row=6, column=2, columnspan=1)
self.st19 = Label(self.EntryFrame, text='Angle', width=10)
self.st19.grid(row=7, column=2, columnspan=1)
self.st20 = Label(self.EntryFrame, text='Length', width=10)
self.st20.grid(row=8, column=2, columnspan=1)
self.FrontAngle = StringVar()
self.FrontAngle.set('60')
self.FrontA = Entry(self.EntryFrame, textvariable=self.FrontAngle, width=5)
self.FrontA.grid(row=7, column=3)
self.FrontDepth = StringVar()
self.FrontDepth.set('20')
self.FrontD = Entry(self.EntryFrame, textvariable=self.FrontDepth, width=5)
self.FrontD.grid(row=8, column=3)
# Reduction Info
self.st21 = Label(self.EntryFrame, text='Reduction', width=10, font="-weight bold")
self.st21.grid(row=6, column=4, columnspan=1)
self.st22 = Label(self.EntryFrame, text='Angle', width=10)
self.st22.grid(row=7, column=4, columnspan=1)
# self.st23 = Label(self.EntryFrame, text='Length' ,width=10)
# self.st23.grid(row=8, column=4, columnspan=1)
self.ReductionAngle = StringVar()
self.ReductionAngle.set('16')
self.ReductionA = Entry(self.EntryFrame, textvariable=self.ReductionAngle, width=5)
self.ReductionA.grid(row=7, column=5)
# self.ReductionDepth = StringVar()
# self.ReductionDepth.set('0')
# self.ReductionD = Entry(self.EntryFrame, textvariable=self.ReductionDepth ,width=5)
# self.ReductionD.grid(row=8, column=5)
# Bearing Info
self.st24 = Label(self.EntryFrame, text='Bearing', width=10, font="-weight bold")
self.st24.grid(row=6, column=6, columnspan=1)
self.st25 = Label(self.EntryFrame, text='Diam.', width=10)
self.st25.grid(row=7, column=6, columnspan=1)
self.st26 = Label(self.EntryFrame, text='Length', width=10)
self.st26.grid(row=8, column=6, columnspan=1)
self.BearingDiameter = StringVar()
self.BearingDiameter.set('.01')
self.BearingDia = Entry(self.EntryFrame, textvariable=self.BearingDiameter, width=5)
self.BearingDia.grid(row=7, column=7)
self.BearingDepth = StringVar()
self.BearingDepth.set('50')
self.BearingD = Entry(self.EntryFrame, textvariable=self.BearingDepth, width=5)
self.BearingD.grid(row=8, column=7)
# Back Info
self.st27 = Label(self.EntryFrame, text='Back', width=10, font="-weight bold")
self.st27.grid(row=6, column=8, columnspan=1)
self.st28 = Label(self.EntryFrame, text='Angle', width=10)
self.st28.grid(row=7, column=8, columnspan=1)
self.st29 = Label(self.EntryFrame, text='Length', width=10)
self.st29.grid(row=8, column=8, columnspan=1)
self.BackAngle = StringVar()
self.BackAngle.set('60')
self.BackA = Entry(self.EntryFrame, textvariable=self.BackAngle, width=5)
self.BackA.grid(row=7, column=9)
self.BackDepth = StringVar()
self.BackDepth.set('20')
self.BackD = Entry(self.EntryFrame, textvariable=self.BackDepth, width=5)
self.BackD.grid(row=8, column=9)
# Create Buttons
self.DoItButton = Button(self.EntryFrame, text='Recalculate', command=self.DoIt)
self.DoItButton.grid(row=12, column=4)
self.SendToAxis = Button(self.EntryFrame, text='Send To Axis', command=self.SendButton)
self.SendToAxis.grid(row=12, column=5)
if IN_AXIS:
self.quitButton = Button(self, text='Write to AXIS and Quit', command=self.WriteToAxis)
else:
self.quitButton = Button(self, text='Quit', command=self.quit)
self.quitButton.grid(row=16, column=1)
self.quit()
def CopyClipboard(self):
self.clipboard_clear()
for line in self.gcode:
self.clipboard_append(line + '\n')
def SendButton(self, obj, data=None):
for line in self.gcode:
sys.stdout.write(line + '\n')
os.system("temp.ngc")
def WriteToAxis(self):
for line in self.gcode:
sys.stdout.write(line + '\n')
self.quit()
def DoIt(self):
for seg in self.segID:
self.PreviewCanvas.delete(seg)
self.segID = []
self.gcode = []
# Current Values
# Check Entrance Current Values
self.ECurrent.configure(bg='white')
if (float(self.ECurrent.get()) < 5.00):
self.ECurrent.configure(bg='red')
return
if (float(self.ECurrent.get()) > 24.99):
self.ECurrent.configure(bg='red')
return
# Check Reduction Current Values
self.RCurrent.configure(bg='white')
if (float(self.RCurrent.get()) < 5.00):
self.RCurrent.configure(bg='red')
return
if (float(self.RCurrent.get()) > 24.99):
self.RCurrent.configure(bg='red')
return
# Check Bearing Current Values
self.BCurrent.configure(bg='white')
if (float(self.BCurrent.get()) < 5.00):
self.BCurrent.configure(bg='red')
return
if (float(self.BCurrent.get()) > 24.99):
self.BCurrent.configure(bg='red')
return
# Check Back Current Values
self.BaCurrent.configure(bg='white')
if (float(self.BaCurrent.get()) < 5.00):
self.BaCurrent.configure(bg='red')
return
if (float(self.BaCurrent.get()) > 24.99):
self.BaCurrent.configure(bg='red')
return
# Q-Switch Values
# Check Entrance Q-Switch Values
self.EQSwitch.configure(bg='white')
if (float(self.EQSwitch.get()) < 500):
self.EQSwitch.configure(bg='red')
return
if (float(self.EQSwitch.get()) > 20000):
self.EQSwitch.configure(bg='red')
return
# Check Reduction Q-Switch Values
self.RQSwitch.configure(bg='white')
if (float(self.RQSwitch.get()) < 500):
self.RQSwitch.configure(bg='red')
return
if (float(self.RQSwitch.get()) > 20000):
self.RQSwitch.configure(bg='red')
return
# Check Bearing Q-Switch Values
self.BQSwitch.configure(bg='white')
if (float(self.BQSwitch.get()) < 500):
self.BQSwitch.configure(bg='red')
return
if (float(self.BQSwitch.get()) > 20000):
self.BQSwitch.configure(bg='red')
return
# Check Back Q-Switch Values
self.BaQSwitch.configure(bg='white')
if (float(self.BaQSwitch.get()) < 500):
self.BaQSwitch.configure(bg='red')
return
if (float(self.BaQSwitch.get()) > 20000):
self.BaQSwitch.configure(bg='red')
return
# Speed values
# Check Entrance Speed Values
self.ESpeed.configure(bg='white')
if (float(self.ESpeed.get()) < 200):
self.ESpeed.configure(bg='red')
return
if (float(self.ESpeed.get()) > 1000):
self.ESpeed.configure(bg='red')
return
# Check Reduction Speed Values
self.RSpeed.configure(bg='white')
if (float(self.RSpeed.get()) < 200):
self.RSpeed.configure(bg='red')
return
if (float(self.RSpeed.get()) > 1000):
self.RSpeed.configure(bg='red')
return
# Check Bearing Speed Values
self.BSpeed.configure(bg='white')
if (float(self.BSpeed.get()) < 200):
self.BSpeed.configure(bg='red')
return
if (float(self.BSpeed.get()) > 1000):
self.BSpeed.configure(bg='red')
return
# Check Back Speed Values
self.BaSpeed.configure(bg='white')
if (float(self.BaSpeed.get()) < 200):
self.BaSpeed.configure(bg='red')
return
if (float(self.BaSpeed.get()) > 1000):
self.BaSpeed.configure(bg='red')
return
# Step values
# Check Entrance Step Values
self.ESteps.configure(bg='white')
if (float(self.ESteps.get()) < .0001):
self.ESteps.configure(bg='red')
return
if (float(self.ESteps.get()) > .01):
self.ESteps.configure(bg='red')
return
return
# Check Reduction Step Values
self.RSteps.configure(bg='white')
if (float(self.RSteps.get()) < .0001):
self.RSteps.configure(bg='red')
return
if (float(self.RSteps.get()) > .01):
self.RSteps.configure(bg='red')
return
# Check Bearing Step Values
self.BSteps.configure(bg='white')
if (float(self.BSteps.get()) < .0001):
self.BSteps.configure(bg='red')
return
if (float(self.BSteps.get()) > .01):
self.BSteps.configure(bg='red')
return
# Check Back Step Values
self.BaSteps.configure(bg='white')
if (float(self.BaSteps.get()) < .0001):
self.BaSteps.configure(bg='red')
return
if (float(self.BaSteps.get()) > .01):
self.BaSteps.configure(bg='red')
return
# Feed values
# Check Entrance Feed Values
self.EFeed.configure(bg='white')
if (float(self.EFeed.get()) < .01):
self.EFeed.configure(bg='red')
return
if (float(self.EFeed.get()) > .5):
self.EFeed.configure(bg='red')
return
# Check Reduction Feed Values
self.RFeed.configure(bg='white')
if (float(self.RFeed.get()) < .01):
self.RFeed.configure(bg='red')
return
if (float(self.RFeed.get()) > .5):
self.RFeed.configure(bg='red')
return
# Check Bearing Feed Values
self.BFeed.configure(bg='white')
if (float(self.BFeed.get()) < .01):
self.BFeed.configure(bg='red')
return
if (float(self.BFeed.get()) > .5):
self.BFeed.configure(bg='red')
return
# Check Back Feed Values
self.BaFeed.configure(bg='white')
if (float(self.BaFeed.get()) < .01):
self.BaFeed.configure(bg='red')
return
if (float(self.BaFeed.get()) > .5):
self.BaFeed.configure(bg='red')
return
# Focal values
# Check Entrance Focal Values
self.EFocal.configure(bg='white')
if (float(self.EFocal.get()) < -.1):
self.EFocal.configure(bg='red')
return
if (float(self.EFocal.get()) > .1):
self.EFocal.configure(bg='red')
return
# Check Reduction Focal Values
self.RFocal.configure(bg='white')
if (float(self.RFocal.get()) < -.1):
self.RFocal.configure(bg='red')
return
if (float(self.RFocal.get()) > .1):
self.RFocal.configure(bg='red')
return
# Check Bearing Focal Values
self.BFocal.configure(bg='white')
if (float(self.BFocal.get()) < -.1):
self.BFocal.configure(bg='red')
return
if (float(self.BFocal.get()) > .1):
self.BFocal.configure(bg='red')
return
# Check Back Overrun Values
self.BaOverrun.configure(bg='white')
if (float(self.BaOverrun.get()) < 0):
self.BaOverrun.configure(bg='red')
return
if (float(self.BaOverrun.get()) > .1):
self.BaOverrun.configure(bg='red')
return
# Thickness, Gap, and Die Dimension Values
# Check Front Die Values
self.FrontA.configure(bg='white')
if (float(self.FrontA.get()) < 35):
self.FrontA.configure(bg='red')
return
if (float(self.FrontA.get()) > 90):
self.FrontA.configure(bg='red')
return
self.FrontD.configure(bg='white')
if (float(self.FrontD.get()) < 1):
self.FrontD.configure(bg='red')
return
if (float(self.FrontD.get()) > 35):
self.FrontD.configure(bg='red')
return
# Check Reduction Die Values
self.ReductionA.configure(bg='white')
if (float(self.ReductionA.get()) < 1):
self.ReductionA.configure(bg='red')
return
if (float(self.ReductionA.get()) > 25):
self.ReductionA.configure(bg='red')
return
# Check Bearing Die Values
self.BearingDia.configure(bg='white')
if (float(self.BearingDia.get()) < .0001):
self.BearingDia.configure(bg='red')
return
if (float(self.BearingDia.get()) > .20):
self.BearingDia.configure(bg='red')
return
self.BearingD.configure(bg='white')
if (float(self.BearingD.get()) < 1):
self.BearingD.configure(bg='red')
return
if (float(self.BearingD.get()) > 100):
self.BearingD.configure(bg='red')
return
# Check Back Die Values
self.BackA.configure(bg='white')
if (float(self.BackA.get()) < 10):
self.BackA.configure(bg='red')
return
if (float(self.BackA.get()) > 90):
self.BackA.configure(bg='red')
return
self.BackD.configure(bg='white')
if (float(self.BackD.get()) < 1):
self.BackD.configure(bg='red')
return
if (float(self.BackD.get()) > 35):
self.BackD.configure(bg='red')
return
# Check Nib Thickness Values
self.NThickness.configure(bg='white')
if (float(self.NThickness.get()) < .01):
self.NThickness.configure(bg='red')
return
if (float(self.NThickness.get()) > .25):
self.NThickness.configure(bg='red')
return
# Temp used for calcs
GapTemp = float(self.BearingDia.get())
GapTempUpper = GapTemp * .75
# Check Gap Values
self.G.configure(bg='white')
if (float(self.G.get()) < 0):
self.G.configure(bg='red')
return
if (float(self.G.get()) > GapTempUpper):
self.G.configure(bg='red')
return
# Variables for G-Code
stonethickness = float(self.NThickness.get())
backdegrees=float(self.BackA.get())
backheight=float(self.BackD.get())
frontdegrees=float(self.FrontA.get())
frontheight=float(self.FrontD.get())
angledegrees=float(self.ReductionA.get())
bearingsize=float(self.BearingDia.get())
bearinglength=float(self.BearingD.get())
centercore=float(self.G.get())
probeenable=float(self.ProbeOn.get())
xprobeposition=float(self.XPPosition.get())
yprobeposition=float(self.YPPosition.get())
zprobeposition=float(self.ZPPosition.get())
backenable=float(self.BackOn.get())
backspindlespeed=float(self.BaSpeed.get())
backfeedrate=float(self.BaFeed.get())
backsteps=float(self.BaSteps.get())
backoverrun=float(self.BaOverrun.get())
backfocaloffset=float(self.BaFocal.get())
backpower=float(self.BaCurrent.get())
backqswitch=float(self.BaQSwitch.get())
backaperature=float(self.BackAp.get())
frontenable=float(self.FrontOn.get())
frontspindlespeed=float(self.ESpeed.get())
frontfeedrate=float(self.EFeed.get())
frontsteps=float(self.ESteps.get())
frontoverrun=float(self.EOverrun.get())
frontfocaloffset=float(self.EFocal.get())
frontpower=float(self.ECurrent.get())
frontqswitch=float(self.EQSwitch.get())
frontaperature=float(self.EntanceAp.get())
reductionenable=float(self.ReductionOn.get())
reductionspindlespeed=float(self.RSpeed.get())
reductionfeedrate=float(self.RFeed.get())
reductionsteps=float(self.RSteps.get())
reductionoverrun=float(self.ROverrun.get())
reductionfocaloffset=float(self.RFocal.get())
reductionpower=float(self.RCurrent.get())
reductionqswitch=float(self.RQSwitch.get())
reductionaperature=float(self.ReductionAp.get())
bearingenable=float(self.BearingOn.get())
bearingspindlespeed=float(self.BSpeed.get())
bearingfeedrate=float(self.BFeed.get())
bearingsteps=float(self.BSteps.get())
bearingoverrun=float(self.BOverrun.get())
bearingfocaloffset=float(self.BFocal.get())
bearingpower=float(self.BCurrent.get())
bearingqswitch=float(self.BQSwitch.get())
bearingaperature=float(self.BearingAp.get())
#Formulas for Drawing
twopi=3.1415*2
degtorad=twopi/360
backangleperside=backdegrees/2
frontangleperside=frontdegrees/2
reductionangleperside=angledegrees/2
bearingradius=bearingsize/2
backbellheight=stonethickness*(backheight/100)
bearingheight=bearingsize*(bearinglength/100)
frontbellheight=stonethickness*(frontheight/100)
reductionheight=stonethickness-(frontbellheight+bearingheight+backbellheight)
reductionradius=((reductionheight*tan(reductionangleperside*degtorad))+bearingradius)
backradius=((backbellheight*tan(backangleperside*degtorad))+bearingradius)
frontradius=(((frontbellheight*tan(frontangleperside*degtorad)))+reductionradius)
if stonethickness >=.001 and stonethickness <= .050:
scale=5000
if stonethickness >=.051 and stonethickness <= .10:
scale=2500
if stonethickness >=.101 and stonethickness <= .250:
scale=1250
else:
scale=2500
#Draw Die
#Draw Back
self.segID.append(self.PreviewCanvas.create_polygon(150-(backradius*scale),290,150-(bearingradius*scale),290-(backbellheight*scale),150+(bearingradius*scale),290-(backbellheight*scale),150+(backradius*scale),290, outline='blue', fill='blue', width=2))
#Draw Bearing
self.segID.append(self.PreviewCanvas.create_polygon(150-(bearingradius*scale), 290-(backbellheight*scale),150-(bearingradius*scale),290-((backbellheight+bearingheight)*scale),150+(bearingradius*scale),290-((backbellheight+bearingheight)*scale),150+(bearingradius*scale),290-(backbellheight*scale), outline='red', fill='red', width=2))
#Draw Reduction
self.segID.append(self.PreviewCanvas.create_polygon(150-(bearingradius*scale),290-((backbellheight+bearingheight)*scale), 150-(reductionradius*scale),290-((backbellheight+bearingheight+reductionheight)*scale), 150+(reductionradius*scale),290-((backbellheight+bearingheight+reductionheight)*scale), 150+(bearingradius*scale),290-((backbellheight+bearingheight)*scale), outline='yellow', fill='yellow', width=2))
#Draw Front
self.segID.append(self.PreviewCanvas.create_polygon(150-(reductionradius*scale),290-((backbellheight+bearingheight+reductionheight)*scale), 150-(frontradius*scale),290-((backbellheight+bearingheight+reductionheight+frontbellheight)*scale), 150+(frontradius*scale),290-((backbellheight+bearingheight+reductionheight+frontbellheight)*scale), 150+(reductionradius*scale),290-((backbellheight+bearingheight+reductionheight)*scale), outline='green', fill='green', width=2))
#Draw Gap
self.segID.append(self.PreviewCanvas.create_polygon(150-((centercore/2)*scale),290,150-((centercore/2)*scale),290-(stonethickness*scale),150+((centercore/2)*scale),290-(stonethickness*scale),150+((centercore/2)*scale),290, outline='white', fill='white', width=0))
self.gcode.append('(Code Generated by Modules.py)')
self.gcode.append('(Modules.py created by Kent Brenneke 01-260-446-5383)')
self.gcode.append('(May 15, 2015)')
self.gcode.append('#1=%.4f (Nib Thickness)' %(stonethickness))
self.gcode.append('#2=%.4f (Back Angle)'%(backdegrees))
self.gcode.append('#3=%.4f (Back Depth)'%(backheight/100))
self.gcode.append('#4=%.4f (Front Angle)'%(frontdegrees))
self.gcode.append('#5=%.4f (Front Depth)'%(frontheight/100))
self.gcode.append('#6=%.4f (Reduction angle)'%(angledegrees))
self.gcode.append('#7=%.4f (Bearing diameter)'%(bearingsize))
self.gcode.append('#8=%.4f (Bearing Length)'%(bearingheight))
self.gcode.append('#11=%.4f (Gap)'%(centercore))
self.gcode.append('#12=%.4f (Probe On)'%(probeenable))
self.gcode.append('#21=%.4f (Probe Z Distance)'%(zprobeposition))
self.gcode.append('#22=%.4f (Probe X Position)'%(xprobeposition))
self.gcode.append('#23=%.4f (Probe Y Position)'%(yprobeposition))
self.gcode.append('#51=[#2/2] (Back Angle Per Side)')
self.gcode.append('#52=[#4/2] (Front Angle Per Side)')
self.gcode.append('#53=[#6/2] (Reduction Angle Per Side)')
self.gcode.append('#54=[#7/2] (Bearing Radius)')
self.gcode.append('#61=[#1*#3] (Back Length)')
self.gcode.append('#62=[#8*#7] (Bearing Length)')
self.gcode.append('#63=[#1*#5] (Front Length)')
self.gcode.append('#64=[#1-[#61+#62+#63]] (Reduction Length)')
self.gcode.append('#70=[#54+[#61*TAN[#51]]] (Back Large Radius)')
self.gcode.append('#71=[#54+[#64*TAN[#53]]] (Reduction Large Radius)')
self.gcode.append('#72=[#71+[#63*TAN[#52]]] (Front Large Radius)')
self.gcode.append('#80=0 (Back Z Height)')
self.gcode.append('#81=0 (Front Z Height)')
self.gcode.append('#82=[0-#63] (Angle Z Height)')
self.gcode.append('#83=[0-[#63+#64]] (Bearing Z Height)')
self.gcode.append('#101=%.4f (Back Spindle Speed)'%(backspindlespeed))
self.gcode.append('#102=%.4f (Back Feedrate)'%(backfeedrate))
self.gcode.append('#103=%.4f (Back Steps)'%(backsteps))
self.gcode.append('#104=%.4f (Back Over Run)'%(backoverrun))
self.gcode.append('#105=%.4f (Back Focal Offset)'%(backfocaloffset))
self.gcode.append('#106=%.4f (Back Power)'%(backpower))
self.gcode.append('#107=%.4f (Back Q-Switch)'%(backqswitch))
self.gcode.append('#108=%.4f (Back Aperature)'%(backaperature))
self.gcode.append('#109=%.4f (Back Enable)'%(backenable))
self.gcode.append('#111=%.4f (Front Spindle Speed)'%(frontspindlespeed))
self.gcode.append('#112=%.4f (Front Feedrate)'%(frontfeedrate))
self.gcode.append('#113=%.4f (Front Steps)'%(frontsteps))
self.gcode.append('#114=%.4f (Front Over Run)'%(frontoverrun))
self.gcode.append('#115=%.4f (Front Focal Offset)'%(frontfocaloffset))
self.gcode.append('#116=%.4f (Front Power)'%(frontpower))
self.gcode.append('#117=%.4f (Front Q-Switch)'%(frontqswitch))
self.gcode.append('#118=%.4f (Front Aperature)'%(frontaperature))
self.gcode.append('#119=%.4f (Front Enable)'%(frontenable))
self.gcode.append('#121=%.4f (Reduction Spindle Speed)'%(reductionspindlespeed))
self.gcode.append('#122=%.4f (Reduction Feedrate)'%(reductionfeedrate))
self.gcode.append('#123=%.4f (Reduction Steps)'%(reductionsteps))
self.gcode.append('#124=%.4f (Reduction Over Run)'%(reductionoverrun))
self.gcode.append('#125=%.4f (Reduction Focal Offset)'%(reductionfocaloffset))
self.gcode.append('#126=%.4f (Reduction Power)'%(reductionpower))
self.gcode.append('#127=%.4f (Reduction Q-Switch)'%(reductionqswitch))
self.gcode.append('#128=%.4f (Reduction Aperature)'%(reductionaperature))
self.gcode.append('#129=%.4f (Reduction Enable)'%(reductionenable))
self.gcode.append('#131=%.4f (Bearing Spindle Speed)'%(bearingspindlespeed))
self.gcode.append('#132=%.4f (Bearing Feedrate)'%(bearingfeedrate))
self.gcode.append('#133=%.4f (Bearing Steps)'%(bearingsteps))
self.gcode.append('#134=%.4f (Bearing Over Run)'%(bearingoverrun))
self.gcode.append('#135=%.4f (Bearing Focal Offset)'%(bearingfocaloffset))
self.gcode.append('#136=%.4f (Bearing Power)'%(bearingpower))
self.gcode.append('#137=%.4f (Bearing Q-Switch)'%(bearingqswitch))
self.gcode.append('#138=%.4f (Bearing Aperature)'%(bearingaperature))
self.gcode.append('#139=%.4f (Bearing Enable)'%(bearingenable))
#Probe
self.gcode.append('M5')
self.gcode.append('M9')
self.gcode.append('M102')
self.gcode.append('M104')
self.gcode.append('M106')
self.gcode.append('G90 G92.1')
self.gcode.append('O<PROBE> IF [#12 EQ 1]')
self.gcode.append('#5223=0')
self.gcode.append('#5063=0')
self.gcode.append('G59')
self.gcode.append('G54')
self.gcode.append('G53 G0 Z0')
self.gcode.append('G0 X#22 Y#23')
self.gcode.append('G0 Z-1.8')
self.gcode.append('G38.2 Z-2.9 F3')
self.gcode.append('G53 G0 Z0')
self.gcode.append('#5223=[#5063-#21]')
self.gcode.append('O<PROBE> ENDIF')
#Back
self.gcode.append('O<BACK> IF [#109 EQ 1]')
self.gcode.append('G90 G59 S#101 M5')
self.gcode.append('G54')
self.gcode.append('M102')
self.gcode.append('M8')
self.gcode.append('M68 E0 Q#106')
self.gcode.append('M68 E1 Q[[50+[[400-50]*[#107-1000]/[40000-1000]]]]')
self.gcode.append('M68 E2 Q#107')
self.gcode.append('G53 G0 Z0')
self.gcode.append('G0 X0 Y0')
self.gcode.append('Z[#80+#105] F#102')
self.gcode.append('G4 P2')
self.gcode.append('M3')
self.gcode.append('G4 P2')
self.gcode.append('O<BACK_AP_ON> IF [#108 EQ 1]')
self.gcode.append('M105')
self.gcode.append('O<BACK_AP_ON> ENDIF>')
self.gcode.append('O<BACK_AP_OFF> IF [#108 NE 1]')
self.gcode.append('M106')
self.gcode.append('O<BACK_AP_OFF> ENDIF')
self.gcode.append('#90=0')
self.gcode.append('O<BACK_STEPS> WHILE [#90 LT[#61+#104]] ')
self.gcode.append('G91')
self.gcode.append('M101')
self.gcode.append('M103')
self.gcode.append('G1 Z-#103')
self.gcode.append('#90=[#90+#103]')
self.gcode.append('Y[[#70-[#11/2]]-[#90*TAN[#51]]]')
self.gcode.append('G1 Y-[#103*TAN[#51]] Z-#103')
self.gcode.append('#90=[#90+#103]')
self.gcode.append('G90')
self.gcode.append('Y[#11/2]')
self.gcode.append('O<BACK_STEPS> ENDWHILE')
self.gcode.append('M102')
self.gcode.append('M105')
self.gcode.append('O<BACK> ENDIF')
#Front
self.gcode.append('O<FRONT> IF [#119 EQ 1]')
self.gcode.append('G90 G59 S#111 M5')
self.gcode.append('G54')
self.gcode.append('M102')
self.gcode.append('M8')
self.gcode.append('M68 E0 Q#116')
self.gcode.append('M68 E1 Q[[50+[[400-50]*[#117-1000]/[40000-1000]]]]')
self.gcode.append('M68 E2 Q#117')
self.gcode.append('G53 G0 Z0')
self.gcode.append('G0 X0 Y0')
self.gcode.append('X0 Y-[#11/2]')
self.gcode.append('Z[#81+#115] F#112')
self.gcode.append('G4 P2')
self.gcode.append('M3')
self.gcode.append('G4 P2')
self.gcode.append('O<FRONT_AP_ON> IF [#118 EQ 1]')
self.gcode.append('M105')
self.gcode.append('O<FRONT_AP_ON> ENDIF>')
self.gcode.append('O<FRONT_AP_OFF> IF [#118 NE 1]')
self.gcode.append('M106')
self.gcode.append('O<FRONT_AP_OFF> ENDIF')
self.gcode.append('#91=0')
self.gcode.append('O<FRONT_STEPS> WHILE [#91 LT[#63+#114]] ')
self.gcode.append('G91')
self.gcode.append('M101')
self.gcode.append('M103')
self.gcode.append('G1 Z-#113')
self.gcode.append('#91=[#91+#113]')
self.gcode.append('Y[[#72-[#11/2]]-[#91*TAN[#52]]]')
self.gcode.append('G1 Y-[#113*TAN[#52]] Z-#113')
self.gcode.append('#91=[#91+#113]')
self.gcode.append('G90')
self.gcode.append('Y[#11/2]')
self.gcode.append('O<FRONT_STEPS> ENDWHILE')
self.gcode.append('M102')
self.gcode.append('O<FRONT> ENDIF')
#Reduction Angle
self.gcode.append('O<REDUCTION> IF [#129 EQ 1]')
self.gcode.append('G90 G59 S#121 M5')
self.gcode.append('G54')
self.gcode.append('M102')
self.gcode.append('M8')
self.gcode.append('M68 E0 Q#126')
self.gcode.append('M68 E1 Q[[50+[[400-50]*[#127-1000]/[40000-1000]]]]')
self.gcode.append('M68 E2 Q#127')
self.gcode.append('G0 Z0')
self.gcode.append('X0 Y0')
self.gcode.append('Z[#82+#125] F#122')
self.gcode.append('X0 Y[#11/2]')
self.gcode.append('M3')
self.gcode.append('O<REDUCTION_AP_ON> IF [#128 EQ 1]')
self.gcode.append('M105')
self.gcode.append('O<REDUCTION_AP_ON> ENDIF>')
self.gcode.append('O<REDUCTION_AP_OFF> IF [#128 NE 1]')
self.gcode.append('M106')
self.gcode.append('O<REDUCTION_AP_OFF> ENDIF')
self.gcode.append('#92=0')
self.gcode.append('O<REDUCTION_STEPS> WHILE [#92 LT[#64+#124]] ')
self.gcode.append('G91')
self.gcode.append('M101')
self.gcode.append('M103')
self.gcode.append('G1 Z-#123')
self.gcode.append('#92=[#92+#123]')
self.gcode.append('Y[[#71-[#11/2]]-[#92*TAN[#53]]]')
self.gcode.append('G1 Y-[#123*TAN[#53]] Z-#123')
self.gcode.append('#92=[#92+#123]')
self.gcode.append('G90')
self.gcode.append('Y[#11/2]')
self.gcode.append('O<REDUCTION_STEPS> ENDWHILE')
self.gcode.append('M102')
self.gcode.append('M105')
self.gcode.append('O<REDUCTION> ENDIF')
#Bearing
self.gcode.append('O<BEARING> IF [#139 EQ 1]')
self.gcode.append('G90 G59 S#131 M5')
self.gcode.append('G54')
self.gcode.append('M102')
self.gcode.append('M8')
self.gcode.append('M68 E0 Q#136')
self.gcode.append('M68 E1 Q[[50+[[400-50]*[#137-1000]/[40000-1000]]]]')
self.gcode.append('M68 E2 Q#137')
self.gcode.append('G0 Z0')
self.gcode.append('X0 Y0')
self.gcode.append('Z[#83+#135] F#132')
self.gcode.append('X0 Y[#11/2]')
self.gcode.append('M3')
self.gcode.append('O<BEARING_AP_ON> IF [#138 EQ 1]')
self.gcode.append('M105')
self.gcode.append('O<BEARING_AP_ON> ENDIF>')
self.gcode.append('O<BEARING_AP_OFF> IF [#138 NE 1]')
self.gcode.append('M106')
self.gcode.append('O<BEARING_AP_OFF> ENDIF')
self.gcode.append('#93=0')
self.gcode.append('O<BEARING_STEPS> WHILE [#93 LT[#62+#134]] ')
self.gcode.append('G91')
self.gcode.append('M101')
self.gcode.append('M103')
self.gcode.append('G1 Z-#133')
self.gcode.append('#93=[#93+#133]')
self.gcode.append('Y[[#54-[#11/2]]-[#93*TAN[#54]]]')
self.gcode.append('G1 Y-[#133*TAN[#54]] Z-#133')
self.gcode.append('#93=[#93+#133]')
self.gcode.append('G90')
self.gcode.append('Y[#11/2]')
self.gcode.append('O<BEARING_STEPS> ENDWHILE')
self.gcode.append('M102')
self.gcode.append('M105')
self.gcode.append('O<BEARING> ENDIF')
#Postamble
self.gcode.append('M5 M9')
self.gcode.append('M102')
self.gcode.append('M104')
self.gcode.append('M106')
self.gcode.append('G54')
self.gcode.append('G53 G0 Z0')
self.gcode.append('G53 G0 X0 Y0')
self.gcode.append('M2')
self.gcode.append('%')
# def get_handlers(halcomp, builder, useropts):
# return [lathe(halcomp, builder, useropts)]
app = Application()
app.master.title("Laser Die Modules by Kent Brenneke")
app.mainloop()
Last edit: 26 Aug 2015 18:54 by BigJohnT. Reason: add code tags
Please Log in or Create an account to join the conversation.
Time to create page: 0.107 seconds