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 c1723f366a..3001ae452e 100644 --- a/src/Mod/CAM/Path/Op/CircularHoleBase.py +++ b/src/Mod/CAM/Path/Op/CircularHoleBase.py @@ -88,24 +88,20 @@ 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 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 @@ -183,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)