diff --git a/src/Mod/Path/PathScripts/PathDeburr.py b/src/Mod/Path/PathScripts/PathDeburr.py index 6d613e5ae6..b60fda27da 100644 --- a/src/Mod/Path/PathScripts/PathDeburr.py +++ b/src/Mod/Path/PathScripts/PathDeburr.py @@ -30,7 +30,7 @@ import PathScripts.PathOp as PathOp import PathScripts.PathOpTools as PathOpTools import math -from PySide import QtCore, QtGui +from PySide import QtCore # lazily loaded modules from lazy_loader.lazy_loader import LazyLoader @@ -54,20 +54,28 @@ def toolDepthAndOffset(width, extraDepth, tool): '''toolDepthAndOffset(width, extraDepth, tool) ... return tuple for given\n parameters.''' - if not (hasattr(tool, 'CuttingEdgeAngle') - and hasattr(tool, 'FlatRadius') - and hasattr(tool, 'Diameter')): - raise ValueError('Deburr requires tool with flatradius, diameter, and CuttingEdgeAngle\n') + if not hasattr(tool, 'Diameter'): + raise ValueError('Deburr requires tool with diameter\n') - angle = float(tool.CuttingEdgeAngle) - if 0 == angle: + if not hasattr(tool, 'CuttingEdgeAngle'): + angle = 180 + FreeCAD.Console.PrintMessage('The selected tool has No CuttingEdgeAngle property. Assuming Endmill\n') + else: + angle = float(tool.CuttingEdgeAngle) + + if not hasattr(tool, 'FlatRadius'): + toolOffset = float(tool.Diameter / 2) + FreeCAD.Console.PrintMessage('The selected tool has no FlatRadius property. Using Diameter\n') + else: + toolOffset = float(tool.FlatRadius) + + if angle == 0: angle = 180 tan = math.tan(math.radians(angle / 2)) toolDepth = 0 if 0 == tan else width / tan depth = toolDepth + extraDepth - toolOffset = float(tool.FlatRadius) - extraOffset = float(tool.Diameter) / 2 - width if 180 == angle else extraDepth / tan + extraOffset = float(tool.Diameter) / 2 - width if angle == 180 else extraDepth / tan offset = toolOffset + extraOffset return (depth, offset) @@ -108,8 +116,9 @@ class ObjectDeburr(PathEngraveBase.ObjectOp): (depth, offset) = toolDepthAndOffset(obj.Width.Value, obj.ExtraDepth.Value, self.tool) except ValueError as e: msg = "{} \n No path will be generated".format(e) - QtGui.QMessageBox.information(None, "Tool Error", msg) - return + raise ValueError(msg) + # QtGui.QMessageBox.information(None, "Tool Error", msg) + # return PathLog.track(obj.Label, depth, offset) @@ -133,22 +142,18 @@ class ObjectDeburr(PathEngraveBase.ObjectOp): self.basewires.extend(basewires) - # Set default value - side = ["Outside"] for w in basewires: self.adjusted_basewires.append(w) - wire = PathOpTools.offsetWire(w, base.Shape, offset, True, side) + wire = PathOpTools.offsetWire(w, base.Shape, offset, True) #, obj.Side) if wire: wires.append(wire) - # Save Outside or Inside - obj.Side = side[0] + # # Save Outside or Inside + # obj.Side = side[0] # Set direction of op - forward = True - if obj.Direction == 'CCW': - forward = False + forward = (obj.Direction == 'CCW') zValues = [] z = 0 diff --git a/src/Mod/Path/PathScripts/PathDeburrGui.py b/src/Mod/Path/PathScripts/PathDeburrGui.py index 18bb832a3f..1d84135d07 100644 --- a/src/Mod/Path/PathScripts/PathDeburrGui.py +++ b/src/Mod/Path/PathScripts/PathDeburrGui.py @@ -62,7 +62,7 @@ class TaskPanelBaseGeometryPage(PathOpGui.TaskPanelBaseGeometryPage): for sub in sel.SubObjects: if isinstance(sub, Part.Face): if sub.normalAt(0, 0) != FreeCAD.Vector(0, 0, 1): - PathLog.info(translate("Path", "Ignoring non-vertical Face")) + PathLog.info(translate("Path", "Ignoring non-horizontal Face")) return self.super().addBaseGeometry(selection) @@ -131,7 +131,6 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage): def taskPanelBaseGeometryPage(self, obj, features): '''taskPanelBaseGeometryPage(obj, features) ... return page for adding base geometries.''' - print(features) return TaskPanelBaseGeometryPage(obj, features) diff --git a/src/Mod/Path/PathScripts/PathEngraveBase.py b/src/Mod/Path/PathScripts/PathEngraveBase.py index 7606ec9b58..dc8689aa91 100644 --- a/src/Mod/Path/PathScripts/PathEngraveBase.py +++ b/src/Mod/Path/PathScripts/PathEngraveBase.py @@ -77,16 +77,20 @@ class ObjectOp(PathOp.ObjectOp): last = None for z in zValues: + PathLog.debug(z) if last: self.appendCommand(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': last.z}), z, relZ, self.vertFeed) first = True if start_idx > len(edges)-1: start_idx = len(edges)-1 - + edges = edges[start_idx:] + edges[:start_idx] for edge in edges: + PathLog.debug("points: {} -> {}".format(edge.Vertexes[0].Point, edge.Vertexes[-1].Point)) + PathLog.debug("valueat {} -> {}".format(edge.valueAt(edge.FirstParameter), edge.valueAt(edge.LastParameter))) if first and (not last or not wire.isClosed()): + PathLog.debug('processing first edge entry') # we set the first move to our first point last = edge.Vertexes[0].Point @@ -96,7 +100,8 @@ class ObjectOp(PathOp.ObjectOp): self.appendCommand(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': last.z}), z, relZ, self.vertFeed) first = False - if PathGeom.pointsCoincide(last, edge.Vertexes[0].Point): + if PathGeom.pointsCoincide(last, edge.valueAt(edge.FirstParameter)): + #if PathGeom.pointsCoincide(last, edge.Vertexes[0].Point): for cmd in PathGeom.cmdsForEdge(edge): self.appendCommand(cmd, z, relZ, self.horizFeed) last = edge.Vertexes[-1].Point diff --git a/src/Mod/Path/PathScripts/PathOpTools.py b/src/Mod/Path/PathScripts/PathOpTools.py index 40e7105ca5..c7c4baf540 100644 --- a/src/Mod/Path/PathScripts/PathOpTools.py +++ b/src/Mod/Path/PathScripts/PathOpTools.py @@ -136,6 +136,7 @@ def orientWire(w, forward=True): If forward = True (the default) the wire is oriented clockwise, looking down the negative Z axis. If forward = False the wire is oriented counter clockwise. If forward = None the orientation is determined by the order in which the edges appear in the wire.''' + PathLog.debug('orienting forward: {}'.format(forward)) wire = Part.Wire(_orientEdges(w.Edges)) if forward is not None: if forward != _isWireClockwise(wire): @@ -144,7 +145,7 @@ def orientWire(w, forward=True): PathLog.track('orientWire - ok') return wire -def offsetWire(wire, base, offset, forward, Side = None): +def offsetWire(wire, base, offset, forward):#, Side = None): '''offsetWire(wire, base, offset, forward) ... offsets the wire away from base and orients the wire accordingly. The function tries to avoid most of the pitfalls of Part.makeOffset2D which is possible because all offsetting happens in the XY plane. @@ -198,12 +199,12 @@ def offsetWire(wire, base, offset, forward, Side = None): if wire.isClosed(): if not base.isInside(owire.Edges[0].Vertexes[0].Point, offset/2, True): PathLog.track('closed - outside') - if Side: - Side[0] = "Outside" + # if Side: + # Side[0] = "Outside" return orientWire(owire, forward) PathLog.track('closed - inside') - if Side: - Side[0] = "Inside" + # if Side: + # Side[0] = "Inside" try: owire = wire.makeOffset2D(-offset) except Exception: # pylint: disable=broad-except