Skip to content

Commit

Permalink
Patch from nahshon
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptonic committed Nov 4, 2016
1 parent c465ca2 commit cb84339
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Mod/Path/Gui/Resources/panels/ProfileEdit.ui
Expand Up @@ -399,6 +399,13 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="processHoles">
<property name="text">
<string>Process Holes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
39 changes: 36 additions & 3 deletions src/Mod/Path/PathScripts/PathProfile.py
Expand Up @@ -98,6 +98,7 @@ def __init__(self, obj):
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Extra value to stay away from final profile- good for roughing toolpath"))
obj.addProperty("App::PropertyLength", "SegLen", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Tesselation value for tool paths made from beziers, bsplines, and ellipses"))
obj.addProperty("App::PropertyAngle", "PlungeAngle", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Plunge angle with which the tool enters the work piece. Straight down is 90 degrees, if set small enough or zero the tool will descent exactly one layer depth down per turn"))
obj.addProperty("App::PropertyBool", "processHoles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Handl holes as well as the outline"))

obj.addProperty("App::PropertyVectorList", "locs", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of holding tag locations"))

Expand Down Expand Up @@ -189,7 +190,7 @@ def _buildPathOCC(self, obj, wire):

return output

def _buildPathLibarea(self, obj, edgelist):
def _buildPathLibarea(self, obj, edgelist, isHole):
import PathScripts.PathKurveUtils as PathKurveUtils
import math
import area
Expand All @@ -210,9 +211,15 @@ def _buildPathLibarea(self, obj, edgelist):
PathKurveUtils.output('mem')
PathKurveUtils.feedrate_hv(self.horizFeed, self.vertFeed)

# Reverse the direction for holes
if isHole:
direction = "CW" if obj.Direction == "CCW" else "CCW"
else:
direction = obj.Direction

output = ""
output += "G0 Z" + str(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n"
curve = PathKurveUtils.makeAreaCurve(edgelist, obj.Direction, startpoint, endpoint)
curve = PathKurveUtils.makeAreaCurve(edgelist, direction, startpoint, endpoint)

'''The following line uses a profile function written for use with FreeCAD. It's clean but incomplete. It doesn't handle
print "x = " + str(point.x)
Expand Down Expand Up @@ -305,6 +312,7 @@ def execute(self, obj):
hfaces = []
vfaces = []
wires = []
holes = []

for b in obj.Base:
for sub in b[1]:
Expand All @@ -319,6 +327,11 @@ def execute(self, obj):
else:
FreeCAD.Console.PrintError(translate("Path", "Face doesn't appear to be parallel or perpendicular to the XY plane. No path will be generated for: \n"))
FreeCAD.Console.PrintError(b[0].Name + "." + sub + "\n")

if obj.processHoles:
for h in hfaces:
holes += h.Wires[1:]

for h in hfaces:
wires.append(h.OuterWire)

Expand All @@ -327,6 +340,19 @@ def execute(self, obj):

wires = wires + slices

for wire in holes:
if obj.Algorithm == "OCC Native":
output += self._buildPathOCC(obj, wire)
else:
try:
import area
except:
FreeCAD.Console.PrintError(translate("Path", "libarea needs to be installed for this command to work.\n"))
return
edgelist = wire.Edges
edgelist = Part.__sortEdges__(edgelist)
output += self._buildPathLibarea(obj, edgelist, True)

for wire in wires:
if obj.Algorithm == "OCC Native":
output += self._buildPathOCC(obj, wire)
Expand All @@ -338,7 +364,7 @@ def execute(self, obj):
return
edgelist = wire.Edges
edgelist = Part.__sortEdges__(edgelist)
output += self._buildPathLibarea(obj, edgelist)
output += self._buildPathLibarea(obj, edgelist, False)

if obj.Active:
path = Path.Path(output)
Expand Down Expand Up @@ -478,6 +504,8 @@ def Activated(self):

FreeCADGui.doCommand('obj.Active = True')

FreeCADGui.doCommand('obj.Algorithm = "libarea"')

FreeCADGui.doCommand('obj.ClearanceHeight = ' + str(ztop + 10.0))
FreeCADGui.doCommand('obj.StepDown = 1.0')
FreeCADGui.doCommand('obj.StartDepth= ' + str(ztop))
Expand All @@ -488,6 +516,7 @@ def Activated(self):
FreeCADGui.doCommand('obj.OffsetExtra = 0.0')
FreeCADGui.doCommand('obj.Direction = "CW"')
FreeCADGui.doCommand('obj.UseComp = False')
FreeCADGui.doCommand('obj.processHoles = False')
FreeCADGui.doCommand('obj.PlungeAngle = 90.0')
#FreeCADGui.doCommand('obj.ActiveTC = None')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
Expand Down Expand Up @@ -547,6 +576,8 @@ def getFields(self):
self.obj.Side = str(self.form.cutSide.currentText())
if hasattr(self.obj, "Direction"):
self.obj.Direction = str(self.form.direction.currentText())
if hasattr(self.obj, "processHoles"):
self.obj.processHoles = self.form.processHoles.isChecked()
self.obj.Proxy.execute(self.obj)

def setFields(self):
Expand All @@ -562,6 +593,7 @@ def setFields(self):
self.form.useCompensation.setChecked(self.obj.UseComp)
self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
self.form.useEndPoint.setChecked(self.obj.UseEndPoint)
self.form.processHoles.setChecked(self.obj.processHoles)

index = self.form.algorithmSelect.findText(
self.obj.Algorithm, QtCore.Qt.MatchFixedString)
Expand Down Expand Up @@ -778,6 +810,7 @@ def setupUi(self):
self.form.extraOffset.editingFinished.connect(self.getFields)
self.form.segLen.editingFinished.connect(self.getFields)
self.form.rollRadius.editingFinished.connect(self.getFields)
self.form.processHoles.clicked.connect(self.getFields)

# Tag Form
QtCore.QObject.connect(
Expand Down

0 comments on commit cb84339

Please sign in to comment.