forked from hugomatic/cncOnline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helicalcircle.py
executable file
·102 lines (86 loc) · 4.02 KB
/
helicalcircle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/python
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# You will find the latest version of this code at the following address:
# http://hugomatic.ca/source/cncOnline
#
# You can contact me at the following email address:
#
import hugomatic.toolkit # the GUI stuff
import hugomatic.code # the GCODE routines
def take_a_break():
"""This function is called when the debug line is printed. Add a breakpoint here
but don't call print, otherwise the program will go into an infinite loop."""
a = 42
# Create the Parameters object. It is used to create the GUI and set values in global variables
params = hugomatic.toolkit.Parameters('Helical circle', 'Round and down',
picture_file="pythonLogo.gif", # picture on the left
debug_callback=take_a_break)
# publish a string. Force the user to select the value from a predetermined list
gcodeUnits = 'Inches'
params.addArgument( gcodeUnits, 'Program units... 1 inch = 25.4 millimeters', choices=('Inches', 'mm'), group='setup' )
# When publishing numbers. the default value determines the type (int or float...)
tool_dia = 0.125
params.addArgument(tool_dia, 'Tool diameter in units', group='setup' )
feed = 4.0
params.addArgument(feed, 'Feed rate in units per minute', group='setup' )
z_safe = 0.1
params.addArgument(z_safe, 'Safe Z above surface in units', group='setup')
z_rapid = 0.05
params.addArgument(z_rapid, 'Rapid plane above surface Z', group='setup')
cut = 0.05
params.addArgument(cut, 'Cut per pass in units', group='setup')
z_depth = -0.1
params.addArgument(z_depth, 'Depth of cut in units', group='setup' )
modes=('Tool outside circle', 'Tool inside circle', 'Tool on circle')
mode = modes[2]
params.addArgument(mode, 'dimensions mode', choices=modes, group='circle' )
x0 = 0.
params.addArgument(x0, 'X center', group='circle' )
y0 = 0.
params.addArgument(y0, 'Y center', group='circle' )
diameter = 1.
params.addArgument(diameter, 'Diameter', group='circle' )
ycount = 1
params.addArgument(ycount, 'Rows', group='grid' )
xcount = 1
params.addArgument(xcount, 'Columns', group='grid' )
dx = 1.
params.addArgument(dx, 'Distance along X', group='grid' )
dy = 1.
params.addArgument(dy, 'Distance along Y', group='grid' )
# Show the GUI, wait for the user to press the OK button
if params.loadParams(): # the result is False if the window is closed without pressing OK
print
print "(circle)"
print
print "(Units: %s)" % gcodeUnits
# generate GCODE here!
hugomatic.code.header(gcodeUnits, feed)
cuts = hugomatic.code.z_cut_compiler(z_depth, cut)
for j in range(ycount):
for i in range (xcount):
x = x0 + i * dx
y = y0 + j * dy
if mode == modes[0]: # tool outside
hugomatic.code.circle_heli_tool_outside(x, y, diameter, z_depth, z_safe, z_rapid, tool_dia, cuts )
if mode == modes[1]: # tool inside
hugomatic.code.circle_heli_tool_inside(x, y, diameter, z_depth, z_safe, z_rapid, tool_dia, cuts )
if mode == modes[2]: # tool on
hugomatic.code.circle_heli(x, y, diameter, z_safe, z_rapid, cuts )
print "g0 Z%.4f (move tool out of the way)" % z_safe
hugomatic.code.footer()