def test11(self): """Verify lead in/out commands for one and a half threads""" center = FreeCAD.Vector() cmd = "G2" zStart = 0 zFinal = 1.5 pitch = 1 radius = 3 leadInOut = True elevator = 2 path, start = threadmilling.generate(center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None) gcode = [ "G0 X0.000000 Y2.000000", "G0 Z0.000000", #'(------- lead-in -------)', "G2 J0.500000 Y3.000000", #'(------- lead-in -------)', "G2 J-3.000000 Y-3.000000 Z0.500000", "G2 J3.000000 Y3.000000 Z1.000000", "G2 J-3.000000 Y-3.000000 Z1.500000", #'(------- lead-out -------)', "G2 I0.000000 J0.500000 X0.000000 Y-2.000000", #'(------- lead-out -------)', ] self.assertEqual([p.toGCode() for p in path], gcode) self.assertCoincide(start, FreeCAD.Vector(0, -2, zFinal))
def test02(self): """Verify thread commands for a one and a half threads""" center = FreeCAD.Vector() cmd = "G2" zStart = 0 zFinal = 1.5 pitch = 1 radius = 3 leadInOut = False elevator = 2 path, start = threadmilling.generate(center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None) gcode = [ "G0 X0.000000 Y2.000000", "G0 Z0.000000", "G1 Y3.000000", "G2 J-3.000000 Y-3.000000 Z0.500000", "G2 J3.000000 Y3.000000 Z1.000000", "G2 J-3.000000 Y-3.000000 Z1.500000", "G1 X0.000000 Y-2.000000", ] self.assertEqual([p.toGCode() for p in path], gcode) self.assertCoincide(start, FreeCAD.Vector(0, -2, zFinal))
def test04(self): """Verify thread commands for a one and 3 quarter threads - CCW""" center = FreeCAD.Vector() cmd = "G3" zStart = 0 zFinal = 1.75 pitch = 1 radius = 3 leadInOut = False elevator = 2 path, start = threadmilling.generate(center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, None) gcode = [ "G0 X0.000000 Y2.000000", "G0 Z0.000000", "G1 Y3.000000", "G3 J-3.000000 Y-3.000000 Z0.500000", "G3 J3.000000 Y3.000000 Z1.000000", "G3 J-3.000000 Y-3.000000 Z1.500000", #'(------- finish-thread -------)', "G3 J3.000000 X3.000000 Y0.000000 Z1.750000", #'(------- finish-thread -------)', "G1 X2.000000 Y0.000000", ] self.assertEqual([p.toGCode() for p in path], gcode) self.assertCoincide(start, FreeCAD.Vector(2, 0, zFinal))
def executeThreadMill(self, obj, loc, gcode, zStart, zFinal, pitch): PathLog.track(obj.Label, loc, gcode, zStart, zFinal, pitch) elevator = elevatorRadius(obj, loc, _isThreadInternal(obj), self.tool) move2clearance = Path.Command("G0", { "Z": obj.ClearanceHeight.Value, "F": self.vertRapid }) self.commandlist.append(move2clearance) start = None for radius in threadPasses( obj.Passes, threadRadii, _isThreadInternal(obj), obj.MajorDiameter.Value, obj.MinorDiameter.Value, float(self.tool.Diameter), float(self.tool.Crest), ): if (not start is None and not _isThreadInternal(obj) and not obj.LeadInOut): # external thread without lead in/out have to go up and over # in other words we need a move to clearance and not take any # shortcuts when moving to the elevator position self.commandlist.append(move2clearance) start = None commands, start = threadmilling.generate( loc, gcode, zStart, zFinal, pitch, radius, obj.LeadInOut, elevator, start, ) for cmd in commands: p = cmd.Parameters if cmd.Name in ["G0"]: p.update({"F": self.vertRapid}) if cmd.Name in ["G1", "G2", "G3"]: p.update({"F": self.horizFeed}) cmd.Parameters = p self.commandlist.extend(commands) self.commandlist.append( Path.Command("G0", { "Z": obj.ClearanceHeight.Value, "F": self.vertRapid }))