Skip to content

Commit

Permalink
Path: more bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptonic authored and yorikvanhavre committed Mar 21, 2017
1 parent 4926bfa commit 09ac25f
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 119 deletions.
5 changes: 2 additions & 3 deletions src/Mod/Path/PathScripts/PathPocket.py
Expand Up @@ -172,8 +172,7 @@ def buildpathlibarea(self, obj, a):
"""Build the pocket path using libarea algorithm"""
import PathScripts.PathAreaUtils as PathAreaUtils
from PathScripts.PathUtils import depth_params

FreeCAD.Console.PrintMessage(translate("PathPocket", "Generating toolpath with libarea offsets.\n"))
PathLog.debug("Generating toolpath with libarea offsets.\n")

depthparams = depth_params(
obj.ClearanceHeight.Value,
Expand Down Expand Up @@ -222,7 +221,7 @@ def buildpathocc(self, obj, shape):
import DraftGeomUtils
from PathScripts.PathUtils import fmt, helicalPlunge, rampPlunge, depth_params

FreeCAD.Console.PrintMessage(translate("PathPocket", "Generating toolpath with OCC native offsets.\n"))
PathLog.debug("Generating toolpath with OCC native offsets.\n")
extraoffset = obj.MaterialAllowance.Value

# Build up the offset loops
Expand Down
13 changes: 4 additions & 9 deletions src/Mod/Path/PathScripts/PathProfile.py
Expand Up @@ -203,12 +203,6 @@ def _buildPathLibarea(self, obj, edgelist, isHole):
lead_in_line_len = 0.0
lead_out_line_len = 0.0

'''
Right here, I need to know the Holding Tags group from the tree that refers to this profile operation and build up the tags for PathKurve Utils.
I need to access the location vector, length, angle in radians and height.
'''
depthparams = depth_params(
obj.ClearanceHeight.Value,
obj.SafeHeight.Value, obj.StartDepth.Value, obj.StepDown.Value, 0.0,
Expand Down Expand Up @@ -244,7 +238,7 @@ def execute(self, obj):
self.radius = tool.Diameter/2

output += "(" + obj.Label + ")"
if obj.Side != "On":
if obj.UseComp:
output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")"
else:
output += "(Uncompensated Tool Path)"
Expand Down Expand Up @@ -386,12 +380,13 @@ def Activated(self):
FreeCADGui.doCommand('obj.SafeHeight = ' + str(ztop + 2.0))
FreeCADGui.doCommand('obj.Side = "Left"')
FreeCADGui.doCommand('obj.OffsetExtra = 0.0')
FreeCADGui.doCommand('obj.Direction = "CCW"')
FreeCADGui.doCommand('obj.UseComp = False')
FreeCADGui.doCommand('obj.Direction = "CW"')
FreeCADGui.doCommand('obj.UseComp = True')
FreeCADGui.doCommand('obj.processHoles = False')
FreeCADGui.doCommand('obj.processPerimeter = True')
FreeCADGui.doCommand('PathScripts.PathProfile._ViewProviderProfile(obj.ViewObject)')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)')

FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
14 changes: 6 additions & 8 deletions src/Mod/Path/PathScripts/PathProfileEdges.py
Expand Up @@ -188,12 +188,6 @@ def _buildPathLibarea(self, obj, edgelist):
lead_in_line_len = 0.0
lead_out_line_len = 0.0

'''
Right here, I need to know the Holding Tags group from the tree that refers to this profile operation and build up the tags for PathKurve Utils.
I need to access the location vector, length, angle in radians and height.
'''
depthparams = depth_params(
obj.ClearanceHeight.Value,
obj.SafeHeight.Value, obj.StartDepth.Value, obj.StepDown.Value, 0.0,
Expand Down Expand Up @@ -228,7 +222,7 @@ def execute(self, obj):
self.radius = tool.Diameter/2

output += "(" + obj.Label + ")"
if obj.Side != "On":
if obj.UseComp:
output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")"
else:
output += "(Uncompensated Tool Path)"
Expand Down Expand Up @@ -358,8 +352,10 @@ def Activated(self):
FreeCADGui.doCommand('obj.Side = "On"')
FreeCADGui.doCommand('obj.OffsetExtra = 0.0')
FreeCADGui.doCommand('obj.Direction = "CW"')
FreeCADGui.doCommand('obj.UseComp = False')
FreeCADGui.doCommand('obj.UseComp = True')

FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)')

FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down Expand Up @@ -451,7 +447,9 @@ def setFields(self):
index = self.form.cutSide.findText(
self.obj.Side, QtCore.Qt.MatchFixedString)
if index >= 0:
self.form.cutSide.blockSignals(True)
self.form.cutSide.setCurrentIndex(index)
self.form.cutSide.blockSignals(False)

index = self.form.direction.findText(
self.obj.Direction, QtCore.Qt.MatchFixedString)
Expand Down
10 changes: 7 additions & 3 deletions src/Mod/Path/PathScripts/PathUtils.py
Expand Up @@ -233,12 +233,16 @@ def findToolController(obj, name=None):
if no controller is found, returns None'''

PathLog.track('name: {}'.format(name))

#First check if a user has selected a tool controller in the tree.
c = None
#First check if a user has selected a tool controller in the tree. Return the first one and remove all from selection
for sel in FreeCADGui.Selection.getSelectionEx():
if hasattr(sel.Object, 'Proxy'):
if isinstance(sel.Object.Proxy, PathScripts.PathLoadTool.LoadTool):
return sel.Object
if c is None:
c = sel.Object
FreeCADGui.Selection.removeSelection(sel.Object)
if c is not None:
return c

controllers = getToolControllers(obj)

Expand Down
11 changes: 8 additions & 3 deletions src/Mod/Path/PathTests/TestPathPost.py
Expand Up @@ -49,15 +49,19 @@ def testLinuxCNC(self):
PathScripts.PathJob.ObjectPathJob(job)
job.Base = self.doc.Box
PathScripts.PathLoadTool.CommandPathLoadTool.Create(job.Name, False)
toolLib = job.Group[0]
tool1 = Path.Tool()
tool1.Diameter = 5.0
tool1.Name = "Default Tool"
tool1.CuttingEdgeHeight = 15.0
tool1.ToolType = "EndMill"
tool1.Material = "HighSpeedSteel"
job.Tooltable.addTools(tool1)
toolLib.ToolNumber = 1

tc = FreeCAD.ActiveDocument.addObject("Path::FeaturePython",'TC')
PathScripts.PathLoadTool.LoadTool(tc)
PathScripts.PathUtils.addToJob(tc, "Job")
tc.Tooltable.setTool(2, tool1)
tc.ToolNumber = 2

self.failUnless(True)

self.doc.getObject("TC").ToolNumber = 2
Expand All @@ -73,6 +77,7 @@ def testLinuxCNC(self):
contour.SafeHeight = 12.0
contour.OffsetExtra = 0.0
contour.Direction = 'CW'
contour.ToolController = tc
contour.UseComp = True
PathScripts.PathUtils.addToJob(contour)
PathScripts.PathContour.ObjectContour.setDepths(contour.Proxy, contour)
Expand Down
189 changes: 96 additions & 93 deletions src/Mod/Path/PathTests/test_linuxcnc_00.ngc
@@ -1,103 +1,106 @@
G17 G90
G21
(TC: UNDEFINED TOOL)
(Default_Tool)
M6 T1.0
M3 S0.0000
(TC)
M6 T2.0
M3 S0.0000
(Contour :TC)
(Contour)
(Uncompensated Tool Path)
G0 Z15.0000
G00 X-0.2500 Y0.0000
G00 X-2.5000 Y0.0000
G00 Z23.0000
G01 X-0.2500 Y0.0000 Z9.0000 F0.00
G01 X-0.2500 Y10.0000 Z9.0000 F0.00
G02 X0.0000 Y10.2500 Z9.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z9.0000 F0.00
G02 X10.2500 Y10.0000 Z9.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z9.0000 F0.00
G02 X10.0000 Y-0.2500 Z9.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z9.0000 F0.00
G02 X-0.2500 Y0.0000 Z9.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z8.0000 F0.00
G01 X-0.2500 Y10.0000 Z8.0000 F0.00
G02 X0.0000 Y10.2500 Z8.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z8.0000 F0.00
G02 X10.2500 Y10.0000 Z8.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z8.0000 F0.00
G02 X10.0000 Y-0.2500 Z8.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z8.0000 F0.00
G02 X-0.2500 Y0.0000 Z8.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z7.0000 F0.00
G01 X-0.2500 Y10.0000 Z7.0000 F0.00
G02 X0.0000 Y10.2500 Z7.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z7.0000 F0.00
G02 X10.2500 Y10.0000 Z7.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z7.0000 F0.00
G02 X10.0000 Y-0.2500 Z7.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z7.0000 F0.00
G02 X-0.2500 Y0.0000 Z7.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z6.0000 F0.00
G01 X-0.2500 Y10.0000 Z6.0000 F0.00
G02 X0.0000 Y10.2500 Z6.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z6.0000 F0.00
G02 X10.2500 Y10.0000 Z6.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z6.0000 F0.00
G02 X10.0000 Y-0.2500 Z6.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z6.0000 F0.00
G02 X-0.2500 Y0.0000 Z6.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z5.0000 F0.00
G01 X-0.2500 Y10.0000 Z5.0000 F0.00
G02 X0.0000 Y10.2500 Z5.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z5.0000 F0.00
G02 X10.2500 Y10.0000 Z5.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z5.0000 F0.00
G02 X10.0000 Y-0.2500 Z5.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z5.0000 F0.00
G02 X-0.2500 Y0.0000 Z5.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z4.0000 F0.00
G01 X-0.2500 Y10.0000 Z4.0000 F0.00
G02 X0.0000 Y10.2500 Z4.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z4.0000 F0.00
G02 X10.2500 Y10.0000 Z4.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z4.0000 F0.00
G02 X10.0000 Y-0.2500 Z4.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z4.0000 F0.00
G02 X-0.2500 Y0.0000 Z4.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z3.0000 F0.00
G01 X-0.2500 Y10.0000 Z3.0000 F0.00
G02 X0.0000 Y10.2500 Z3.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z3.0000 F0.00
G02 X10.2500 Y10.0000 Z3.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z3.0000 F0.00
G02 X10.0000 Y-0.2500 Z3.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z3.0000 F0.00
G02 X-0.2500 Y0.0000 Z3.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z2.0000 F0.00
G01 X-0.2500 Y10.0000 Z2.0000 F0.00
G02 X0.0000 Y10.2500 Z2.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z2.0000 F0.00
G02 X10.2500 Y10.0000 Z2.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z2.0000 F0.00
G02 X10.0000 Y-0.2500 Z2.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z2.0000 F0.00
G02 X-0.2500 Y0.0000 Z2.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z1.0000 F0.00
G01 X-0.2500 Y10.0000 Z1.0000 F0.00
G02 X0.0000 Y10.2500 Z1.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z1.0000 F0.00
G02 X10.2500 Y10.0000 Z1.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z1.0000 F0.00
G02 X10.0000 Y-0.2500 Z1.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z1.0000 F0.00
G02 X-0.2500 Y0.0000 Z1.0000 I0.0000 J0.2500 F0.00
G01 X-0.2500 Y0.0000 Z0.0000 F0.00
G01 X-0.2500 Y10.0000 Z0.0000 F0.00
G02 X0.0000 Y10.2500 Z0.0000 I0.2500 J0.0000 F0.00
G01 X10.0000 Y10.2500 Z0.0000 F0.00
G02 X10.2500 Y10.0000 Z0.0000 I0.0000 J-0.2500 F0.00
G01 X10.2500 Y0.0000 Z0.0000 F0.00
G02 X10.0000 Y-0.2500 Z0.0000 I-0.2500 J0.0000 F0.00
G01 X0.0000 Y-0.2500 Z0.0000 F0.00
G02 X-0.2500 Y0.0000 Z0.0000 I0.0000 J0.2500 F0.00
G01 X-2.5000 Y0.0000 Z9.0000 F0.00
G01 X-2.5000 Y10.0000 Z9.0000 F0.00
G02 X0.0000 Y12.5000 Z9.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z9.0000 F0.00
G02 X12.5000 Y10.0000 Z9.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z9.0000 F0.00
G02 X10.0000 Y-2.5000 Z9.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z9.0000 F0.00
G02 X-2.5000 Y0.0000 Z9.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z8.0000 F0.00
G01 X-2.5000 Y10.0000 Z8.0000 F0.00
G02 X0.0000 Y12.5000 Z8.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z8.0000 F0.00
G02 X12.5000 Y10.0000 Z8.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z8.0000 F0.00
G02 X10.0000 Y-2.5000 Z8.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z8.0000 F0.00
G02 X-2.5000 Y0.0000 Z8.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z7.0000 F0.00
G01 X-2.5000 Y10.0000 Z7.0000 F0.00
G02 X0.0000 Y12.5000 Z7.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z7.0000 F0.00
G02 X12.5000 Y10.0000 Z7.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z7.0000 F0.00
G02 X10.0000 Y-2.5000 Z7.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z7.0000 F0.00
G02 X-2.5000 Y0.0000 Z7.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z6.0000 F0.00
G01 X-2.5000 Y10.0000 Z6.0000 F0.00
G02 X0.0000 Y12.5000 Z6.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z6.0000 F0.00
G02 X12.5000 Y10.0000 Z6.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z6.0000 F0.00
G02 X10.0000 Y-2.5000 Z6.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z6.0000 F0.00
G02 X-2.5000 Y0.0000 Z6.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z5.0000 F0.00
G01 X-2.5000 Y10.0000 Z5.0000 F0.00
G02 X0.0000 Y12.5000 Z5.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z5.0000 F0.00
G02 X12.5000 Y10.0000 Z5.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z5.0000 F0.00
G02 X10.0000 Y-2.5000 Z5.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z5.0000 F0.00
G02 X-2.5000 Y0.0000 Z5.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z4.0000 F0.00
G01 X-2.5000 Y10.0000 Z4.0000 F0.00
G02 X0.0000 Y12.5000 Z4.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z4.0000 F0.00
G02 X12.5000 Y10.0000 Z4.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z4.0000 F0.00
G02 X10.0000 Y-2.5000 Z4.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z4.0000 F0.00
G02 X-2.5000 Y0.0000 Z4.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z3.0000 F0.00
G01 X-2.5000 Y10.0000 Z3.0000 F0.00
G02 X0.0000 Y12.5000 Z3.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z3.0000 F0.00
G02 X12.5000 Y10.0000 Z3.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z3.0000 F0.00
G02 X10.0000 Y-2.5000 Z3.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z3.0000 F0.00
G02 X-2.5000 Y0.0000 Z3.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z2.0000 F0.00
G01 X-2.5000 Y10.0000 Z2.0000 F0.00
G02 X0.0000 Y12.5000 Z2.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z2.0000 F0.00
G02 X12.5000 Y10.0000 Z2.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z2.0000 F0.00
G02 X10.0000 Y-2.5000 Z2.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z2.0000 F0.00
G02 X-2.5000 Y0.0000 Z2.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z1.0000 F0.00
G01 X-2.5000 Y10.0000 Z1.0000 F0.00
G02 X0.0000 Y12.5000 Z1.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z1.0000 F0.00
G02 X12.5000 Y10.0000 Z1.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z1.0000 F0.00
G02 X10.0000 Y-2.5000 Z1.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z1.0000 F0.00
G02 X-2.5000 Y0.0000 Z1.0000 I0.0000 J2.5000 F0.00
G01 X-2.5000 Y0.0000 Z0.0000 F0.00
G01 X-2.5000 Y10.0000 Z0.0000 F0.00
G02 X0.0000 Y12.5000 Z0.0000 I2.5000 J0.0000 F0.00
G01 X10.0000 Y12.5000 Z0.0000 F0.00
G02 X12.5000 Y10.0000 Z0.0000 I0.0000 J-2.5000 F0.00
G01 X12.5000 Y0.0000 Z0.0000 F0.00
G02 X10.0000 Y-2.5000 Z0.0000 I-2.5000 J0.0000 F0.00
G01 X0.0000 Y-2.5000 Z0.0000 F0.00
G02 X-2.5000 Y0.0000 Z0.0000 I0.0000 J2.5000 F0.00
G00 Z15.0000
M05
G00 X-1.0 Y1.0
Expand Down

0 comments on commit 09ac25f

Please sign in to comment.