Merge pull request #27514 from tarman3/holes_diameter

CAM: CircularHoleBase - Fix holeDiameter() for face
This commit is contained in:
sliptonic
2026-03-13 12:45:43 -05:00
committed by GitHub
3 changed files with 14 additions and 24 deletions
+4 -10
View File
@@ -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"""
+9 -13
View File
@@ -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),
}
)
+1 -1
View File
@@ -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)