From c909b753a4b83e6dd45d00c0ceaae591f97facbd Mon Sep 17 00:00:00 2001 From: sliptonic Date: Mon, 19 Dec 2022 14:32:07 -0600 Subject: [PATCH] Fix for Partial edge drilling Fixes 8131 --- src/Mod/Path/Path/Base/Drillable.py | 22 +++++++++++++++++----- src/Mod/Path/Path/Op/Gui/Selection.py | 6 +++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Mod/Path/Path/Base/Drillable.py b/src/Mod/Path/Path/Base/Drillable.py index ea9d4b37fa..23f02f4af6 100644 --- a/src/Mod/Path/Path/Base/Drillable.py +++ b/src/Mod/Path/Path/Base/Drillable.py @@ -167,7 +167,9 @@ def isDrillableFace(obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1 return True -def isDrillableEdge(obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1)): +def isDrillableEdge( + obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1), allowPartial=False +): """ checks if an edge is drillable """ @@ -181,10 +183,15 @@ def isDrillableEdge(obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1 ) edge = candidate - if not (isinstance(edge.Curve, Part.Circle) and edge.isClosed()): - Path.Log.debug("expected a closed circular edge") + if not (isinstance(edge.Curve, Part.Circle)): + Path.Log.debug("expected a circular edge") return False + if isinstance(edge.Curve, Part.Circle): + if not (allowPartial or edge.isClosed()): + Path.Log.debug("expected a closed circular edge or allow partial") + return False + if not hasattr(edge.Curve, "Radius"): Path.Log.debug("The Feature edge has no radius - Ellipse.") return False @@ -203,7 +210,9 @@ def isDrillableEdge(obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1 return True -def isDrillable(obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1)): +def isDrillable( + obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1), allowPartial=False +): """ Checks candidates to see if they can be drilled at the given vector. Candidates can be either faces - circular or cylindrical or circular edges. @@ -214,10 +223,13 @@ def isDrillable(obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1)): for any candidate not drillable in this orientation. Pass 'None' to vector to test whether the hole is drillable at any orientation. + allowPartial will permit selecting partial circular arcs manually. + obj=Shape candidate = Face or Edge tooldiameter=float vector=App.Vector or None + allowPartial boolean """ Path.Log.debug( @@ -242,7 +254,7 @@ def isDrillable(obj, candidate, tooldiameter=None, vector=App.Vector(0, 0, 1)): else: return isDrillableFace(obj, candidate, tooldiameter, vector) if candidate.ShapeType == "Edge": - return isDrillableEdge(obj, candidate, tooldiameter, vector) + return isDrillableEdge(obj, candidate, tooldiameter, vector, allowPartial) else: return False diff --git a/src/Mod/Path/Path/Op/Gui/Selection.py b/src/Mod/Path/Path/Op/Gui/Selection.py index 9044e54a55..059cf0d9c3 100644 --- a/src/Mod/Path/Path/Op/Gui/Selection.py +++ b/src/Mod/Path/Path/Op/Gui/Selection.py @@ -29,8 +29,8 @@ import Path import Path.Base.Drillable as Drillable import math -Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule()) -# Path.Log.trackModule(Path.Log.thisModule()) +Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule()) +Path.Log.trackModule(Path.Log.thisModule()) class PathBaseGate(object): @@ -129,7 +129,7 @@ class DRILLGate(PathBaseGate): subobj = shape.getElement(sub) if subobj.ShapeType not in ["Edge", "Face"]: return False - return Drillable.isDrillable(shape, subobj, vector=None) + return Drillable.isDrillable(shape, subobj, vector=None, allowPartial=True) class FACEGate(PathBaseGate):