From 034d9ec21a64ca4da8213044ed99423e45c318d9 Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Tue, 4 May 2021 15:56:45 +0100 Subject: [PATCH] use toolbits with tooltip calculation --- src/Mod/Path/PathScripts/PathUtils.py | 33 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathUtils.py b/src/Mod/Path/PathScripts/PathUtils.py index d2e18e7184..5152ae044a 100644 --- a/src/Mod/Path/PathScripts/PathUtils.py +++ b/src/Mod/Path/PathScripts/PathUtils.py @@ -745,18 +745,29 @@ def guessDepths(objshape, subs=None): def drillTipLength(tool): """returns the length of the drillbit tip.""" - if not hasattr(tool, 'CuttingEdgeAngle') or tool.CuttingEdgeAngle == 180 or tool.CuttingEdgeAngle == 0.0 or float(tool.Diameter) == 0.0: + + if isinstance(tool, Path.Tool): + PathLog.error(translate("Path", "Legacy Tools not supported")) return 0.0 - else: - if tool.CuttingEdgeAngle <= 0 or tool.CuttingEdgeAngle >= 180: - PathLog.error(translate("Path", "Invalid Cutting Edge Angle %.2f, must be >0° and <=180°") % tool.CuttingEdgeAngle) - return 0.0 - theta = math.radians(tool.CuttingEdgeAngle) - length = (float(tool.Diameter) / 2) / math.tan(theta / 2) - if length < 0: - PathLog.error(translate("Path", "Cutting Edge Angle (%.2f) results in negative tool tip length") % tool.CuttingEdgeAngle) - return 0.0 - return length + + if not hasattr(tool, 'TipAngle'): + PathLog.error(translate("Path", "Selected tool is not a drill")) + return 0.0 + + angle = tool.TipAngle + + if angle <= 0 or angle >= 180: + PathLog.error(translate("Path", "Invalid Cutting Edge Angle %.2f, must be >0° and <=180°") % angle) + return 0.0 + + theta = math.radians(angle) + length = (float(tool.Diameter) / 2) / math.tan(theta / 2) + + if length < 0: + PathLog.error(translate("Path", "Cutting Edge Angle (%.2f) results in negative tool tip length") % angle) + return 0.0 + + return length class depth_params(object):