From 9874444dbaa87df207766904e651732ad4568bf4 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Sat, 8 Jul 2017 17:54:29 -0500 Subject: [PATCH] Path: add feature for drill tip calculation --- .../Path/Gui/Resources/panels/DrillingEdit.ui | 20 +++++++++++++---- src/Mod/Path/PathScripts/PathDrilling.py | 22 ++++++++++++++----- src/Mod/Path/PathScripts/PathUtils.py | 9 ++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/DrillingEdit.ui b/src/Mod/Path/Gui/Resources/panels/DrillingEdit.ui index 15ca064d06..c8f006fc11 100644 --- a/src/Mod/Path/Gui/Resources/panels/DrillingEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/DrillingEdit.ui @@ -22,6 +22,9 @@ + + If true, the length of the drillpoint will be calculated and added to the final depth + 3 @@ -33,8 +36,8 @@ 0 0 - 304 - 319 + 303 + 344 @@ -46,8 +49,7 @@ - - + @@ -162,6 +164,16 @@ + + + + If enabled, drill depth is increased by tip length + + + use tip length + + + diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index 27ff53d000..94d9fe71eb 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -74,6 +74,7 @@ class ObjectDrilling: obj.addProperty("App::PropertyLength", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z")) obj.addProperty("App::PropertyFloat", "DwellTime", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The time to dwell between peck cycles")) obj.addProperty("App::PropertyBool", "DwellEnabled", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Enable dwell")) + obj.addProperty("App::PropertyBool", "AddTipLength", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Calculate the tip length and subtract from final depth")) # Heights & Depths obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions")) @@ -132,6 +133,10 @@ class ObjectDrilling: else: self.radius = tool.Diameter/2 + tiplength = 0.0 + if obj.AddTipLength: + tiplength = PathUtils.drillTipLength(tool) + if len(obj.Names) == 0: parentJob = PathUtils.findParentJob(obj) if parentJob is None: @@ -170,7 +175,7 @@ class ObjectDrilling: diameters = [] for h in holes: if len(names) == 0: - self.findHeights(obj, baseobject, h) + self.setDepths(obj, baseobject, h) names.append(h['featureName']) positions.append(FreeCAD.Vector(h['x'], h['y'], 0)) enabled.append(1) @@ -211,7 +216,7 @@ class ObjectDrilling: output += cmd + \ " X" + fmt(p['x']) + \ " Y" + fmt(p['y']) + \ - " Z" + fmt(obj.FinalDepth.Value) + qword + pword + \ + " Z" + fmt(obj.FinalDepth.Value - tiplength) + qword + pword + \ " R" + str(obj.RetractHeight.Value) + \ " F" + str(self.vertFeed) + "\n" \ @@ -219,10 +224,8 @@ class ObjectDrilling: path = Path.Path(output) obj.Path = path - # obj.ViewObject.Visibility = True - - def findHeights(self, obj, bobj, hole): + def setDepths(self, obj, bobj, hole): try: bb = bobj.Shape.BoundBox subobj = hole['feature'] @@ -346,6 +349,7 @@ class CommandPathDrilling: FreeCADGui.doCommand('obj.FinalDepth=' + str(zbottom)) FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') + # FreeCADGui.doCommand('PathScripts.PathDrilling.ObjectDrilling.setDepths(obj.Proxy, obj)') FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.doCommand('obj.ViewObject.startEditing()') @@ -414,6 +418,8 @@ class TaskPanel: PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc + if hasattr(self.obj, "AddTipLength"): + self.obj.AddTipLength = self.form.chkTipDepth.isChecked() except ValueError: self.setFields() self.isDirty = True @@ -465,6 +471,11 @@ class TaskPanel: else: self.form.peckEnabled.setCheckState(QtCore.Qt.Unchecked) + if self.obj.AddTipLength: + self.form.chkTipDepth.setCheckState(QtCore.Qt.Checked) + else: + self.form.chkTipDepth.setCheckState(QtCore.Qt.Unchecked) + self.updateFeatureList() controllers = PathUtils.getToolControllers(self.obj) @@ -610,6 +621,7 @@ class TaskPanel: self.form.dwellTime.editingFinished.connect(self.getFields) self.form.dwellEnabled.stateChanged.connect(self.getFields) self.form.peckEnabled.stateChanged.connect(self.getFields) + self.form.chkTipDepth.stateChanged.connect(self.getFields) # buttons self.form.uiEnableSelected.clicked.connect(self.enableSelected) diff --git a/src/Mod/Path/PathScripts/PathUtils.py b/src/Mod/Path/PathScripts/PathUtils.py index b7931145c1..58192aff77 100644 --- a/src/Mod/Path/PathScripts/PathUtils.py +++ b/src/Mod/Path/PathScripts/PathUtils.py @@ -730,6 +730,15 @@ def guessDepths(objshape, subs=None): return depth_params(clearance, safe, start, 1.0, 0.0, final, user_depths=None, equalstep=False) +def drillTipLength(tool): + """returns the length of the drillbit tip. +""" + if tool.CuttingEdgeAngle == 0.0 or tool.Diameter == 0.0: + return 0.0 + else: + theta = math.radians(tool.CuttingEdgeAngle) + return (tool.Diameter/2) / math.tan(theta) + class depth_params: '''calculates the intermediate depth values for various operations given the starting, ending, and stepdown parameters