From dc339325553d99fffab9f52b875f148664d1266e Mon Sep 17 00:00:00 2001 From: phaseloop <90922095+phaseloop@users.noreply.github.com> Date: Mon, 27 Jan 2025 18:03:43 +0100 Subject: [PATCH] CAM: Fix finishing pass (#17960) * CAM: Fix finishing pass * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add finishing pass unit (by @baehr) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/CAM/CAMTests/TestPathVcarve.py | 30 ++++++++++++++++++++++++++ src/Mod/CAM/Path/Op/Vcarve.py | 11 ++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/Mod/CAM/CAMTests/TestPathVcarve.py b/src/Mod/CAM/CAMTests/TestPathVcarve.py index 42ddbf3509..f1beb771a9 100644 --- a/src/Mod/CAM/CAMTests/TestPathVcarve.py +++ b/src/Mod/CAM/CAMTests/TestPathVcarve.py @@ -21,6 +21,8 @@ # *************************************************************************** import FreeCAD +import Part +import Path.Main.Job as PathJob import Path.Op.Vcarve as PathVcarve import Path.Tool.Bit as PathToolBit import math @@ -44,6 +46,34 @@ Scale60 = math.sqrt(3) class TestPathVcarve(PathTestBase): """Test Vcarve milling basics.""" + def tearDown(self): + if hasattr(self, "doc"): + FreeCAD.closeDocument(self.doc.Name) + + def testFinishingPass(self): + self.doc = FreeCAD.newDocument() + part = FreeCAD.ActiveDocument.addObject("Part::Feature", "TestShape") + rect = Part.makePolygon([(0, 0, 0), (5, 0, 0), (5, 10, 0), (0, 10, 0), (0, 0, 0)]) + part.Shape = Part.makeFace(rect, "Part::FaceMakerSimple") + job = PathJob.Create("Job", [part]) + tool_file = PathToolBit.findToolBit("60degree_Vbit.fctb") + job.Tools.Group[0].Tool = PathToolBit.Factory.CreateFrom(tool_file) + + op = PathVcarve.Create("TestVCarve") + op.Base = job.Model.Group[0] + + op.FinishingPass = False + op.Proxy.execute(op) + min_z_no_finish = op.Path.BoundBox.ZMin + + finishing_offset = -0.1 + op.FinishingPass = True + op.FinishingPassZOffset = finishing_offset + op.Proxy.execute(op) + min_z_with_finish = op.Path.BoundBox.ZMin + + self.assertRoughly(min_z_with_finish - min_z_no_finish, finishing_offset) + def test00(self): """Verify 90 deg depth calculation""" tool = VbitTool(10, 90, 0) diff --git a/src/Mod/CAM/Path/Op/Vcarve.py b/src/Mod/CAM/Path/Op/Vcarve.py index 527efd0509..179c6799a7 100644 --- a/src/Mod/CAM/Path/Op/Vcarve.py +++ b/src/Mod/CAM/Path/Op/Vcarve.py @@ -505,15 +505,12 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): while geom.incrementStepDownDepth(maximumUsableDepth): cutWires(wires, pathlist, obj.OptimizeMovements) - # add finishing pass if enabled + # add finishing pass if enabled - # if obj.FinishingPass: - # geom.offset = obj.FinishingPassZOffset.Value + if obj.FinishingPass: + geom.offset = obj.FinishingPassZOffset.Value - # for w in wires: - # pWire = self._getPartEdges(obj, w, geom) - # if pWire: - # pathlist.extend(cutWire(pWire)) + cutWires(wires, pathlist, obj.OptimizeMovements) self.commandlist = pathlist