示例#1
0
    def circularHoleExecute(self, obj, holes):
        """circularHoleExecute(obj, holes) ... generate helix commands for each hole in holes"""
        PathLog.track()
        self.commandlist.append(Path.Command("(helix cut operation)"))

        self.commandlist.append(
            Path.Command("G0", {"Z": obj.ClearanceHeight.Value}))

        holes = sort_locations(holes, ["x", "y"])

        tool = obj.ToolController.Tool
        tooldiamter = (tool.Diameter.Value
                       if hasattr(tool.Diameter, "Value") else tool.Diameter)

        args = {
            "edge": None,
            "hole_radius": None,
            "step_down": obj.StepDown.Value,
            "step_over": obj.StepOver / 100,
            "tool_diameter": tooldiamter,
            "inner_radius": obj.StartRadius.Value + obj.OffsetExtra.Value,
            "direction": obj.Direction,
            "startAt": obj.StartSide,
        }

        for hole in holes:
            args["hole_radius"] = (hole["r"] / 2) - (obj.OffsetExtra.Value)
            startPoint = FreeCAD.Vector(hole["x"], hole["y"],
                                        obj.StartDepth.Value)
            endPoint = FreeCAD.Vector(hole["x"], hole["y"],
                                      obj.FinalDepth.Value)
            args["edge"] = Part.makeLine(startPoint, endPoint)

            # move to starting position
            self.commandlist.append(
                Path.Command("G0", {"Z": obj.ClearanceHeight.Value}))
            self.commandlist.append(
                Path.Command(
                    "G0",
                    {
                        "X": startPoint.x,
                        "Y": startPoint.y,
                        "Z": obj.ClearanceHeight.Value,
                    },
                ))
            self.commandlist.append(
                Path.Command("G0", {
                    "X": startPoint.x,
                    "Y": startPoint.y,
                    "Z": startPoint.z
                }))

            results = helix_generator.generate(**args)

            for command in results:
                self.commandlist.append(command)

        PathFeedRate.setFeedRate(self.commandlist, obj.ToolController)
示例#2
0
    def test00(self):
        """Test Basic Helix Generator Return"""
        args = _resetArgs()
        result = generator.generate(**args)
        self.assertTrue(type(result) is list)
        self.assertTrue(type(result[0]) is Path.Command)

        gcode = "".join([r.toGCode() for r in result])
        self.assertTrue(gcode == self.expectedHelixGCode,
                        "Incorrect helix g-code generated")
示例#3
0
    def test10(self):
        """Test Helix Retraction"""

        # if center is clear, the second to last move should be a rapid away
        # from the wall
        args = _resetArgs()
        v1 = FreeCAD.Vector(0, 0, 20)
        v2 = FreeCAD.Vector(0, 0, 18)
        edg = Part.makeLine(v1, v2)
        args["edge"] = edg
        args["inner_radius"] = 0.0
        args["tool_diameter"] = 5.0
        result = generator.generate(**args)
        self.assertTrue(result[-2].Name == "G0")

        # if center is not clear, retraction is one straight up on the last
        # move. the second to last move should be a G2
        args["inner_radius"] = 2.0
        result = generator.generate(**args)
        self.assertTrue(result[-2].Name == "G2")