Path: add feature for drill tip calculation

This commit is contained in:
sliptonic
2017-07-08 17:54:29 -05:00
committed by Yorik van Havre
parent 6c52548750
commit 9874444dba
3 changed files with 42 additions and 9 deletions

View File

@@ -22,6 +22,9 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QToolBox" name="toolBox">
<property name="toolTip">
<string>If true, the length of the drillpoint will be calculated and added to the final depth</string>
</property>
<property name="currentIndex">
<number>3</number>
</property>
@@ -33,8 +36,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>304</width>
<height>319</height>
<width>303</width>
<height>344</height>
</rect>
</property>
<attribute name="icon">
@@ -46,8 +49,7 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="3">
<widget class="QTableWidget" name="baseList">
</widget>
<widget class="QTableWidget" name="baseList"/>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="uiEnableSelected">
@@ -162,6 +164,16 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkTipDepth">
<property name="toolTip">
<string>If enabled, drill depth is increased by tip length</string>
</property>
<property name="text">
<string>use tip length</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="Heights">

View File

@@ -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)

View File

@@ -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