Merge pull request #13 from zobotek/master
Update to support 'write to file', other minor changes
This commit is contained in:
commit
26f58ae3be
2 changed files with 39 additions and 28 deletions
|
|
@ -12,7 +12,7 @@ Features
|
|||
|
||||
* Can drill circular, elliptical, rectangular or oval rectangular shaped array of holes with triangular or square hole patterns
|
||||
* Usable as an axis filter program
|
||||
* G-Code can be copied to the clipboard for easy insertion into other gcode programs
|
||||
* G-Code can be written to a file or copied to the clipboard for easy insertion into other gcode programs
|
||||
|
||||
Screenshot
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Grill.py G-Code Generator
|
||||
Version 1.7
|
||||
Version 1.8
|
||||
Copyright (C) <2018> <Alex Bobotek> <alex at bobotek dot net>
|
||||
|
||||
based on work by <Lawrence Glaister> and <John Thornton> -- thanks Lawrence and John!
|
||||
|
|
@ -29,16 +29,17 @@
|
|||
Version 1.5 changed 'EMC2' in comments to 'LinuxCNC', modified to run in Python 2 and Python 3, added hole diameter and % open area comments to gcode output
|
||||
Version 1.6 added square hole pattern option
|
||||
Version 1.7 added write to file button and function
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
Version 1.8 reversed Y axis order
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
from tkinter import filedialog
|
||||
from tkinter import *
|
||||
else:
|
||||
from Tkinter import tkFileDialog
|
||||
from Tkinter import *
|
||||
else:
|
||||
from Tkinter import *
|
||||
import Tkinter, Tkconstants, tkFileDialog
|
||||
from math import *
|
||||
import os
|
||||
import math
|
||||
|
|
@ -238,7 +239,7 @@ class Application(Frame):
|
|||
|
||||
# erase old gcode as needed
|
||||
self.gcode = []
|
||||
self.gcode.append('( Code generated by grill.py widget )')
|
||||
self.gcode.append('( Code generated by grill.py version 1.8 )')
|
||||
self.gcode.append('( by Alex Bobotek - 2018 )')
|
||||
self.gcode.append(self.PreambleVar.get())
|
||||
self.gcode.append( 'G0 Z%.4f F%s' %(float(self.SafeZVar.get()), self.FeedspeedVar.get()))
|
||||
|
|
@ -251,11 +252,14 @@ class Application(Frame):
|
|||
PercentOpenArea = 100*math.pi*(float(self.DrillVar.get())/2.0)*(float(self.DrillVar.get())/2.0) / (float(self.HoleSpaceVar.get())*float(self.HoleSpaceVar.get()))
|
||||
if self.ShapeVar.get() == 0:
|
||||
# temps used for circular grills
|
||||
self.gcode.append('( %.4f dia circular grill at %.4f,%.4f with %.3f diameter holes spaced %.3f and %.3f percent open area)'
|
||||
self.gcode.append('( %.4f dia circular grill at %.4f,%.4f )'
|
||||
|
||||
%(float(self.GrillXVar.get()),
|
||||
float(self.XGrillCenterVar.get()),
|
||||
float(self.YGrillCenterVar.get()),
|
||||
float(self.DrillVar.get()),
|
||||
float(self.YGrillCenterVar.get())
|
||||
))
|
||||
self.gcode.append('( %.3f diameter holes spaced %.3f and %.3f percent open area )'
|
||||
%(float(self.DrillVar.get()),
|
||||
float(self.HoleSpaceVar.get()),
|
||||
PercentOpenArea
|
||||
))
|
||||
|
|
@ -271,15 +275,17 @@ class Application(Frame):
|
|||
|
||||
if self.ShapeVar.get() == 1: # ellipse
|
||||
# temps used for elliptical grills
|
||||
self.gcode.append('( %.4fx%.4f elliptical grill at %.4f,%.4f with %.3f diameter holes spaced %.3f and %.3f percent open area)'
|
||||
self.gcode.append('( %.4fx%.4f elliptical grill at %.4f,%.4f )'
|
||||
%(float(self.GrillXVar.get()),
|
||||
float(self.GrillYVar.get()),
|
||||
float(self.XGrillCenterVar.get()),
|
||||
float(self.YGrillCenterVar.get()),
|
||||
float(self.DrillVar.get()),
|
||||
float(self.YGrillCenterVar.get())
|
||||
))
|
||||
self.gcode.append('( %.3f diameter holes spaced %.3f and %.3f percent open area )'
|
||||
%(float(self.DrillVar.get()),
|
||||
float(self.HoleSpaceVar.get()),
|
||||
PercentOpenArea
|
||||
))
|
||||
))
|
||||
|
||||
self.GrillY.configure(state=NORMAL)
|
||||
a = float(self.GrillXVar.get())/2.0
|
||||
|
|
@ -298,16 +304,19 @@ class Application(Frame):
|
|||
|
||||
if self.ShapeVar.get() == 2: # rectangle
|
||||
# temps used for rectangular grills
|
||||
self.gcode.append('( %.4fx%.4f rectangular grill at %.4f,%.4f with %.3f diameter holes spaced %.3f and %.3f percent open area)'
|
||||
self.gcode.append('( %.4fx%.4f rectangular grill at %.4f,%.4f )'
|
||||
%(float(self.GrillXVar.get()),
|
||||
float(self.GrillYVar.get()),
|
||||
float(self.XGrillCenterVar.get()),
|
||||
float(self.YGrillCenterVar.get()),
|
||||
float(self.DrillVar.get()),
|
||||
float(self.YGrillCenterVar.get())
|
||||
))
|
||||
self.gcode.append('( %.3f diameter holes spaced %.3f and %.3f percent open area )'
|
||||
%(float(self.DrillVar.get()),
|
||||
float(self.HoleSpaceVar.get()),
|
||||
PercentOpenArea
|
||||
))
|
||||
|
||||
|
||||
self.GrillY.configure(state=NORMAL)
|
||||
a = float(self.GrillXVar.get())/2.0
|
||||
b = float(self.GrillYVar.get())/2.0
|
||||
|
|
@ -323,12 +332,14 @@ class Application(Frame):
|
|||
|
||||
if self.ShapeVar.get() == 3: # oval
|
||||
# temps used for oval grills
|
||||
self.gcode.append('( %.4fx%.4f oval grill at %.4f,%.4f with %.3f diameter holes spaced %.3f and %.3f percent open area)'
|
||||
self.gcode.append('( %.4fx%.4f oval grill at %.4f,%.4f )'
|
||||
%(float(self.GrillXVar.get()),
|
||||
float(self.GrillYVar.get()),
|
||||
float(self.XGrillCenterVar.get()),
|
||||
float(self.YGrillCenterVar.get()),
|
||||
float(self.DrillVar.get()),
|
||||
float(self.YGrillCenterVar.get())
|
||||
))
|
||||
self.gcode.append('( %.3f diameter holes spaced %.3f and %.3f percent open area)'
|
||||
%(float(self.DrillVar.get()),
|
||||
float(self.HoleSpaceVar.get()),
|
||||
PercentOpenArea
|
||||
))
|
||||
|
|
@ -361,7 +372,7 @@ class Application(Frame):
|
|||
# grid computed so it is always symmetrical about center point
|
||||
for x in range(-xholes,xholes):
|
||||
for y in range(-yholes-1,yholes+1):
|
||||
CurY = y * YSpacing
|
||||
CurY = -y * YSpacing
|
||||
if (y % 2)==0:
|
||||
CurX = x * Spacing
|
||||
else:
|
||||
|
|
@ -442,5 +453,5 @@ class Application(Frame):
|
|||
self.quit()
|
||||
|
||||
app = Application()
|
||||
app.master.title("Grill.py 1.7 by Alex Bobotek and Lawrence Glaister")
|
||||
app.master.title("Grill.py 1.8 by Alex Bobotek and Lawrence Glaister")
|
||||
app.mainloop()
|
||||
|
|
|
|||
Loading…
Reference in a new issue