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>
This commit is contained in:
phaseloop
2025-01-27 18:03:43 +01:00
committed by GitHub
parent 77a05049d5
commit dc33932555
2 changed files with 34 additions and 7 deletions

View File

@@ -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)

View File

@@ -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