CAM: Vcarve - fix zStart

This commit is contained in:
tarman3
2025-06-02 22:53:37 +03:00
parent db1b5a8773
commit c30407cbbf
2 changed files with 15 additions and 9 deletions

View File

@@ -51,16 +51,22 @@ class TestPathVcarve(PathTestWithAssets):
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])
part1 = FreeCAD.ActiveDocument.addObject("Part::Feature", "TestShape")
part2 = FreeCAD.ActiveDocument.addObject("Part::Feature", "TestShape")
rect = Part.makePolygon(
[(20, 20, 10), (25, 20, 10), (25, 30, 10), (20, 30, 10), (20, 20, 10)]
)
box = Part.makeBox(100, 100, 10)
part1.Shape = box
part2.Shape = Part.makeFace(rect, "Part::FaceMakerSimple")
job = PathJob.Create("Job", [part1, part2])
toolbit = self.assets.get("toolbit://60degree_Vbit")
loaded_tool = toolbit.attach_to_doc(doc=job.Document)
job.Tools.Group[0].Tool = loaded_tool
op = PathVcarve.Create("TestVCarve")
op.Base = job.Model.Group[0]
op.BaseShapes = job.Model.Group[1]
op.FinishingPass = False
op.Proxy.execute(op)
@@ -72,7 +78,7 @@ class TestPathVcarve(PathTestWithAssets):
op.Proxy.execute(op)
min_z_with_finish = op.Path.BoundBox.ZMin
self.assertRoughly(min_z_with_finish - min_z_no_finish, finishing_offset)
self.assertRoughly(min_z_with_finish - min_z_no_finish, finishing_offset, 1.0)
def test00(self):
"""Verify 90 deg depth calculation"""

View File

@@ -204,8 +204,8 @@ class _Geometry(object):
return _Geometry(zStart + zOff, max(zStop + zOff, zFinal), zScale, zStepDown)
@classmethod
def FromObj(cls, obj, model):
zStart = model.Shape.BoundBox.ZMax
def FromObj(cls, obj):
zStart = obj.BaseShapes[0].Shape.BoundBox.ZMax
finalDepth = obj.FinalDepth.Value
stepDown = abs(obj.StepDown.Value)
@@ -500,7 +500,7 @@ class ObjectVcarve(PathEngraveBase.ObjectOp):
# iterate over each face separately
for face, wires in self.buildMedialWires(obj, faces).items():
geom = _Geometry.FromObj(obj, self.model[0])
geom = _Geometry.FromObj(obj)
# If using depth step-down, calculate maximum usable depth for current face.
# This is done to avoid adding additional step-down engraving passes when it