25
import Path.Tool.Bit as PathToolBit
26
import Path.Tool.Controller as PathToolController
28
from Tests.PathTestUtils import PathTestBase
31
class TestPathToolController(PathTestBase):
33
self.doc = FreeCAD.newDocument("TestPathToolController")
34
FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True")
37
FreeCAD.closeDocument(self.doc.Name)
38
FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "")
40
def createTool(self, name="t1", diameter=1.75):
44
"parameter": {"Diameter": diameter},
47
return PathToolBit.Factory.CreateFromAttrs(attrs, name)
50
"""Verify ToolController templateAttrs"""
51
t = self.createTool("T1")
52
tc = PathToolController.Create("TC0", t)
54
tc.Label = "ToolController"
56
tc.VertFeed = "3 in/s"
57
tc.VertFeed = round(tc.VertFeed, 1)
58
tc.HorizFeed = "10 mm/s"
61
tc.SpindleDir = "Reverse"
62
tc.SpindleSpeed = 12000
64
attrs = tc.Proxy.templateAttrs(tc)
66
self.assertEqual(attrs["name"], "TC0")
67
self.assertEqual(attrs["label"], "ToolController")
68
self.assertEqual(attrs["nr"], 7)
69
self.assertEqual(attrs["vfeed"], "76.2 mm/s")
70
self.assertEqual(attrs["hfeed"], "10.0 mm/s")
71
self.assertEqual(attrs["vrapid"], "40.0 mm/s")
72
self.assertEqual(attrs["hrapid"], "28.0 mm/s")
73
self.assertEqual(attrs["dir"], "Reverse")
74
self.assertEqual(attrs["speed"], 12000)
75
self.assertEqual(attrs["tool"], t.Proxy.templateAttrs(t))
80
"""Verify ToolController template roundtrip."""
83
tc1 = PathToolController.FromTemplate(tc0.Proxy.templateAttrs(tc0))
85
self.assertNotEqual(tc0.Name, tc1.Name)
86
self.assertNotEqual(tc0.Label, tc1.Label)
87
self.assertEqual(tc0.ToolNumber, tc1.ToolNumber)
88
self.assertRoughly(tc0.VertFeed, tc1.VertFeed)
89
self.assertRoughly(tc0.HorizFeed, tc1.HorizFeed)
90
self.assertRoughly(tc0.VertRapid, tc1.VertRapid)
91
self.assertRoughly(tc0.HorizRapid, tc1.HorizRapid)
92
self.assertEqual(tc0.SpindleDir, tc1.SpindleDir)
93
self.assertRoughly(tc0.SpindleSpeed, tc1.SpindleSpeed)
98
self.assertRoughly(tc0.Tool.Diameter, tc1.Tool.Diameter)