2
# ***************************************************************************
3
# * Copyright (c) 2019 sliptonic <shopinthewoods@gmail.com> *
5
# * This program is free software; you can redistribute it and/or modify *
6
# * it under the terms of the GNU Lesser General Public License (LGPL) *
7
# * as published by the Free Software Foundation; either version 2 of *
8
# * the License, or (at your option) any later version. *
9
# * for detail see the LICENCE text file. *
11
# * This program is distributed in the hope that it will be useful, *
12
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
# * GNU Library General Public License for more details. *
16
# * You should have received a copy of the GNU Library General Public *
17
# * License along with this program; if not, write to the Free Software *
18
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
21
# ***************************************************************************
24
import Path.Base.Generator.threadmilling as threadmilling
27
from Tests.PathTestUtils import PathTestBase
30
def radii(internal, major, minor, toolDia, toolCrest):
31
"""test radii function for simple testing"""
35
class TestPathThreadMillingGenerator(PathTestBase):
36
"""Test thread milling generator."""
39
"""Verify thread commands for a single thread"""
41
center = FreeCAD.Vector()
50
path, start = threadmilling.generate(
51
center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None
55
"G0 X0.000000 Y2.000000",
58
"G2 J-3.000000 Y-3.000000 Z0.500000",
59
"G2 J3.000000 Y3.000000 Z1.000000",
60
"G1 X0.000000 Y2.000000",
62
self.assertEqual([p.toGCode() for p in path], gcode)
63
self.assertCoincide(start, FreeCAD.Vector(0, 2, zFinal))
66
"""Verify thread commands for a thwo threads"""
68
center = FreeCAD.Vector()
77
path, start = threadmilling.generate(
78
center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None
82
"G0 X0.000000 Y2.000000",
85
"G2 J-3.000000 Y-3.000000 Z0.500000",
86
"G2 J3.000000 Y3.000000 Z1.000000",
87
"G2 J-3.000000 Y-3.000000 Z1.500000",
88
"G2 J3.000000 Y3.000000 Z2.000000",
89
"G1 X0.000000 Y2.000000",
91
self.assertEqual([p.toGCode() for p in path], gcode)
92
self.assertCoincide(start, FreeCAD.Vector(0, 2, zFinal))
95
"""Verify thread commands for a one and a half threads"""
97
center = FreeCAD.Vector()
106
path, start = threadmilling.generate(
107
center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None
111
"G0 X0.000000 Y2.000000",
114
"G2 J-3.000000 Y-3.000000 Z0.500000",
115
"G2 J3.000000 Y3.000000 Z1.000000",
116
"G2 J-3.000000 Y-3.000000 Z1.500000",
117
"G1 X0.000000 Y-2.000000",
119
self.assertEqual([p.toGCode() for p in path], gcode)
120
self.assertCoincide(start, FreeCAD.Vector(0, -2, zFinal))
123
"""Verify thread commands for a one and 3 quarter threads"""
125
center = FreeCAD.Vector()
134
path, start = threadmilling.generate(
135
center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None
139
"G0 X0.000000 Y2.000000",
142
"G2 J-3.000000 Y-3.000000 Z0.500000",
143
"G2 J3.000000 Y3.000000 Z1.000000",
144
"G2 J-3.000000 Y-3.000000 Z1.500000",
145
#'(------- finish-thread -------)',
146
"G2 J3.000000 X-3.000000 Y0.000000 Z1.750000",
147
#'(------- finish-thread -------)',
148
"G1 X-2.000000 Y0.000000",
150
self.assertEqual([p.toGCode() for p in path], gcode)
151
self.assertCoincide(start, FreeCAD.Vector(-2, 0, zFinal))
154
"""Verify thread commands for a one and 3 quarter threads - CCW"""
156
center = FreeCAD.Vector()
165
path, start = threadmilling.generate(
166
center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None
170
"G0 X0.000000 Y2.000000",
173
"G3 J-3.000000 Y-3.000000 Z0.500000",
174
"G3 J3.000000 Y3.000000 Z1.000000",
175
"G3 J-3.000000 Y-3.000000 Z1.500000",
176
#'(------- finish-thread -------)',
177
"G3 J3.000000 X3.000000 Y0.000000 Z1.750000",
178
#'(------- finish-thread -------)',
179
"G1 X2.000000 Y0.000000",
181
self.assertEqual([p.toGCode() for p in path], gcode)
182
self.assertCoincide(start, FreeCAD.Vector(2, 0, zFinal))
185
"""Verify lead in/out commands for a single thread"""
187
center = FreeCAD.Vector()
196
path, start = threadmilling.generate(
197
center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None
201
"G0 X0.000000 Y2.000000",
203
#'(------- lead-in -------)',
204
"G2 J0.500000 Y3.000000",
205
#'(------- lead-in -------)',
206
"G2 J-3.000000 Y-3.000000 Z0.500000",
207
"G2 J3.000000 Y3.000000 Z1.000000",
208
#'(------- lead-out -------)',
209
"G2 I0.000000 J-0.500000 X0.000000 Y2.000000",
210
#'(------- lead-out -------)',
212
self.assertEqual([p.toGCode() for p in path], gcode)
213
self.assertCoincide(start, FreeCAD.Vector(0, 2, zFinal))
216
"""Verify lead in/out commands for one and a half threads"""
218
center = FreeCAD.Vector()
227
path, start = threadmilling.generate(
228
center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None
232
"G0 X0.000000 Y2.000000",
234
#'(------- lead-in -------)',
235
"G2 J0.500000 Y3.000000",
236
#'(------- lead-in -------)',
237
"G2 J-3.000000 Y-3.000000 Z0.500000",
238
"G2 J3.000000 Y3.000000 Z1.000000",
239
"G2 J-3.000000 Y-3.000000 Z1.500000",
240
#'(------- lead-out -------)',
241
"G2 I0.000000 J0.500000 X0.000000 Y-2.000000",
242
#'(------- lead-out -------)',
244
self.assertEqual([p.toGCode() for p in path], gcode)
245
self.assertCoincide(start, FreeCAD.Vector(0, -2, zFinal))