25
import Path.Base.Drillable as Drillable
26
import Tests.PathTestUtils as PathTestUtils
30
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
31
Path.Log.trackModule(Path.Log.thisModule())
33
Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule())
36
class TestPathDrillable(PathTestUtils.PathTestBase):
38
App.ConfigSet("SuppressRecomputeRequiredDialog", "True")
39
self.doc = App.open(App.getHomePath() + "/Mod/CAM/Tests/Drilling_1.FCStd")
40
App.ConfigSet("SuppressRecomputeRequiredDialog", "")
41
self.obj = self.doc.getObject("Pocket011")
44
App.closeDocument(self.doc.Name)
47
"""Test CompareVecs"""
50
v1 = App.Vector(0, 0, 10)
51
v2 = App.Vector(0, 0, 0)
52
self.assertTrue(Drillable.compareVecs(v1, v2))
55
v1 = App.Vector(0, 10, 0)
56
v2 = App.Vector(0, 20, 0)
57
self.assertTrue(Drillable.compareVecs(v1, v2))
60
v1 = App.Vector(0, 10, 0)
61
v2 = App.Vector(10, 0, 0)
62
self.assertFalse(Drillable.compareVecs(v1, v2))
65
"""Test isDrillable"""
68
candidate = self.obj.getSubObject("Vertex1")
69
self.assertRaises(TypeError, lambda: Drillable.isDrillable(self.obj.Shape, candidate))
74
candidate = self.obj.getSubObject("Face30")
77
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate))
80
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, tooldiameter=20))
83
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate, tooldiameter=30))
86
candidate = self.obj.getSubObject("Face44")
89
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
92
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
96
Drillable.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, -1, 0))
101
Drillable.isDrillable(
102
self.obj.Shape, candidate, tooldiameter=10, vector=App.Vector(0, -1, 0)
108
Drillable.isDrillable(
109
self.obj.Shape, candidate, tooldiameter=30, vector=App.Vector(0, -1, 0)
114
candidate = self.obj.getSubObject("Face29")
117
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
120
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
123
candidate = self.obj.getSubObject("Face32")
126
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
129
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
132
candidate = self.obj.getSubObject("Face24")
134
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate))
137
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
140
candidate = self.obj.getSubObject("Face54")
143
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate))
146
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
150
Drillable.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 0, 1))
154
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, tooldiameter=10))
157
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate, tooldiameter=30))
160
candidate = self.obj.getSubObject("Face58")
163
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
166
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
170
Drillable.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, -1, 0))
174
candidate = self.obj.getSubObject("Face49")
176
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate))
179
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
182
candidate = self.obj.getSubObject("Face50")
184
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
187
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
190
candidate = self.obj.getSubObject("Face48")
192
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate))
195
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
199
candidate = self.obj.getSubObject("Edge55")
202
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate))
205
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
209
Drillable.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 0, 1))
213
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, tooldiameter=10))
217
Drillable.isDrillable(self.obj.Shape, candidate, tooldiameter=30, vector=None)
221
candidate = self.obj.getSubObject("Edge74")
224
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
227
self.assertTrue(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
231
Drillable.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 1, 0))
235
candidate = self.obj.getSubObject("Edge39")
237
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
240
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
243
candidate = self.obj.getSubObject("Edge56")
245
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate))
248
self.assertFalse(Drillable.isDrillable(self.obj.Shape, candidate, vector=None))
251
"""Test getDrillableTargets"""
252
results = Drillable.getDrillableTargets(self.obj)
253
self.assertEqual(len(results), 15)
255
results = Drillable.getDrillableTargets(self.obj, vector=None)
256
self.assertEqual(len(results), 20)
258
results = Drillable.getDrillableTargets(self.obj, ToolDiameter=20, vector=None)
259
self.assertEqual(len(results), 5)