From eaf76e4d0a97a1292d1c3b17f34961835c4d73bd Mon Sep 17 00:00:00 2001 From: tarman3 Date: Wed, 11 Feb 2026 21:07:13 +0200 Subject: [PATCH 1/2] CAM: CircularHoleBase.holeDiameter() - Fix face --- src/Mod/CAM/Path/Op/CircularHoleBase.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Mod/CAM/Path/Op/CircularHoleBase.py b/src/Mod/CAM/Path/Op/CircularHoleBase.py index 48e4625fe4..39613eaaaa 100644 --- a/src/Mod/CAM/Path/Op/CircularHoleBase.py +++ b/src/Mod/CAM/Path/Op/CircularHoleBase.py @@ -92,20 +92,16 @@ class ObjectOp(PathOp.ObjectOp): """holeDiameter(obj, base, sub) ... returns the diameter of the specified hole.""" try: shape = base.Shape.getElement(sub) - if shape.ShapeType == "Vertex": + if isinstance(shape, Part.Vertex): return 0 - if shape.ShapeType == "Edge" and type(shape.Curve) == Part.Circle: + if isinstance(shape, Part.Edge) and isinstance(shape.Curve, Part.Circle): return shape.Curve.Radius * 2 - if shape.ShapeType == "Face": - for i in range(len(shape.Edges)): - if ( - type(shape.Edges[i].Curve) == Part.Circle - and shape.Edges[i].Curve.Radius * 2 < shape.BoundBox.XLength * 1.1 - and shape.Edges[i].Curve.Radius * 2 > shape.BoundBox.XLength * 0.9 - ): - return shape.Edges[i].Curve.Radius * 2 + if isinstance(shape, Part.Face): + for edge in shape.Edges: + if isinstance(edge.Curve, Part.Circle): + return edge.Curve.Radius * 2 # for all other shapes the diameter is just the dimension in X. # This may be inaccurate as the BoundBox is calculated on the tessellated geometry From eb0d7ba6a50886182ca7ed5b3cef2b30ef056545 Mon Sep 17 00:00:00 2001 From: tarman3 Date: Thu, 26 Feb 2026 13:48:34 +0200 Subject: [PATCH 2/2] CAM: CircularHoleBase.holeDiameter() - Remove useless obj --- src/Mod/CAM/CAMTests/TestPathHelix.py | 14 ++++---------- src/Mod/CAM/Path/Op/CircularHoleBase.py | 6 +++--- src/Mod/CAM/Path/Op/Gui/CircularHoleBase.py | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Mod/CAM/CAMTests/TestPathHelix.py b/src/Mod/CAM/CAMTests/TestPathHelix.py index fc050e60a8..83026d23a8 100644 --- a/src/Mod/CAM/CAMTests/TestPathHelix.py +++ b/src/Mod/CAM/CAMTests/TestPathHelix.py @@ -72,7 +72,7 @@ class TestPathHelix(PathTestUtils.PathTestBase): model = base[0] for sub in base[1]: pos = proxy.holePosition(model, sub) - self.assertRoughly(round(pos.Length / 10, 0), proxy.holeDiameter(op, model, sub)) + self.assertRoughly(round(pos.Length / 10, 0), proxy.holeDiameter(model, sub)) def test02(self): """Verify Helix generates proper holes for rotated model""" @@ -88,9 +88,7 @@ class TestPathHelix(PathTestUtils.PathTestBase): for sub in base[1]: pos = proxy.holePosition(model, sub) # Path.Log.track(deg, pos, pos.Length) - self.assertRoughly( - round(pos.Length / 10, 0), proxy.holeDiameter(op, model, sub) - ) + self.assertRoughly(round(pos.Length / 10, 0), proxy.holeDiameter(model, sub)) def test03(self): """Verify Helix generates proper holes for rotated base model""" @@ -112,9 +110,7 @@ class TestPathHelix(PathTestUtils.PathTestBase): for sub in base[1]: pos = proxy.holePosition(model, sub) # Path.Log.track(deg, pos, pos.Length) - self.assertRoughly( - round(pos.Length / 10, 0), proxy.holeDiameter(op, model, sub) - ) + self.assertRoughly(round(pos.Length / 10, 0), proxy.holeDiameter(model, sub)) def test04(self): """Verify Helix generates proper holes for rotated clone base model""" @@ -136,9 +132,7 @@ class TestPathHelix(PathTestUtils.PathTestBase): for sub in base[1]: pos = proxy.holePosition(model, sub) # Path.Log.track(deg, pos, pos.Length) - self.assertRoughly( - round(pos.Length / 10, 0), proxy.holeDiameter(op, model, sub) - ) + self.assertRoughly(round(pos.Length / 10, 0), proxy.holeDiameter(model, sub)) def testPathDirection(self): """Verify that the generated paths obeys the given parameters""" diff --git a/src/Mod/CAM/Path/Op/CircularHoleBase.py b/src/Mod/CAM/Path/Op/CircularHoleBase.py index 39613eaaaa..f431146240 100644 --- a/src/Mod/CAM/Path/Op/CircularHoleBase.py +++ b/src/Mod/CAM/Path/Op/CircularHoleBase.py @@ -88,8 +88,8 @@ class ObjectOp(PathOp.ObjectOp): Can safely be overwritten by subclasses.""" pass - def holeDiameter(self, obj, base, sub): - """holeDiameter(obj, base, sub) ... returns the diameter of the specified hole.""" + def holeDiameter(self, base, sub): + """holeDiameter(base, sub) ... returns the diameter of the specified hole.""" try: shape = base.Shape.getElement(sub) if isinstance(shape, Part.Vertex): @@ -179,7 +179,7 @@ class ObjectOp(PathOp.ObjectOp): { "x": pos.x, "y": pos.y, - "r": self.holeDiameter(obj, base, sub), + "r": self.holeDiameter(base, sub), } ) diff --git a/src/Mod/CAM/Path/Op/Gui/CircularHoleBase.py b/src/Mod/CAM/Path/Op/Gui/CircularHoleBase.py index 37b6d5b6b1..66cf6b2145 100644 --- a/src/Mod/CAM/Path/Op/Gui/CircularHoleBase.py +++ b/src/Mod/CAM/Path/Op/Gui/CircularHoleBase.py @@ -84,7 +84,7 @@ class TaskPanelHoleGeometryPage(PathOpGui.TaskPanelBaseGeometryPage): item.setData(self.DataObjectSub, sub) self.form.baseList.setItem(self.form.baseList.rowCount() - 1, 0, item) - dia = obj.Proxy.holeDiameter(obj, base, sub) + dia = obj.Proxy.holeDiameter(base, sub) item = QtGui.QTableWidgetItem() item.setData(QtCore.Qt.DisplayRole, float(dia)) item.setTextAlignment(QtCore.Qt.AlignHCenter)