diff --git a/src/Mod/Path/PathScripts/PathDeburr.py b/src/Mod/Path/PathScripts/PathDeburr.py index 2dac9b36e3..fb5e969155 100644 --- a/src/Mod/Path/PathScripts/PathDeburr.py +++ b/src/Mod/Path/PathScripts/PathDeburr.py @@ -234,16 +234,24 @@ class ObjectDeburr(PathEngraveBase.ObjectOp): self.basewires.extend(basewires) + # Set default side + side = ["Outside"] for w in basewires: self.adjusted_basewires.append(w) - wire = PathOpTools.offsetWire(w, base.Shape, offset, True) + wire = PathOpTools.offsetWire(w, base.Shape, offset, True, side) if wire: wires.append(wire) # Set direction of op forward = (obj.Direction == 'CW') + # Set value of side + obj.Side = side[0] + # Check side extra for angled faces + if radius_top > radius_bottom: + obj.Side = "Inside" + zValues = [] z = 0 if obj.StepDown.Value != 0: diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 64fc18e1ac..137cf71ee7 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -113,6 +113,7 @@ class ObjectDressup: def getDirectionOfPath(self, obj): op = PathDressup.baseOp(obj.Base) + if hasattr(op, 'Side') and op.Side == 'Outside': if hasattr(op, 'Direction') and op.Direction == 'CW': return 'left' @@ -131,12 +132,16 @@ class ObjectDressup: return '' def normalize(self, Vector): + vx = 0 + vy = 0 + x = Vector.x y = Vector.y length = math.sqrt(x*x + y*y) if((math.fabs(length)) > 0.0000000000001): vx = round(x / length, 3) vy = round(y / length, 3) + return FreeCAD.Vector(vx, vy, 0) def invert(self, Vector): diff --git a/src/Mod/Path/PathScripts/PathGeom.py b/src/Mod/Path/PathScripts/PathGeom.py index 5c70b63701..21585435d3 100644 --- a/src/Mod/Path/PathScripts/PathGeom.py +++ b/src/Mod/Path/PathScripts/PathGeom.py @@ -350,8 +350,11 @@ def edgeForCmd(cmd, startPoint): PathLog.debug("StartPoint:{}".format(startPoint)) PathLog.debug("MidPoint:{}".format(midPoint)) PathLog.debug("EndPoint:{}".format(endPoint)) - - return Part.Edge(Part.Arc(startPoint, midPoint, endPoint)) + + if pointsCoincide(startPoint, endPoint, 0.001): + return Part.makeCircle(R, center, FreeCAD.Vector(0, 0, 1)) + else: + return Part.Edge(Part.Arc(startPoint, midPoint, endPoint)) # It's a Helix #print('angle: A=%.2f B=%.2f' % (getAngle(A)/math.pi, getAngle(B)/math.pi)) diff --git a/src/Mod/Path/PathScripts/PathOpTools.py b/src/Mod/Path/PathScripts/PathOpTools.py index de7c2e19fb..83cdb5c3e8 100644 --- a/src/Mod/Path/PathScripts/PathOpTools.py +++ b/src/Mod/Path/PathScripts/PathOpTools.py @@ -143,7 +143,7 @@ def orientWire(w, forward=True): PathLog.track('orientWire - ok') return wire -def offsetWire(wire, base, offset, forward): +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. @@ -163,6 +163,9 @@ def offsetWire(wire, base, offset, forward): if offset > curve.Radius or PathGeom.isRoughly(offset, curve.Radius): # offsetting a hole by its own radius (or more) makes the hole vanish return None + if Side: + Side[0] = "Inside" + print("inside") new_edge = Part.makeCircle(curve.Radius - offset, curve.Center, FreeCAD.Vector(0, 0, -z)) return Part.Wire([new_edge]) @@ -186,6 +189,9 @@ def offsetWire(wire, base, offset, forward): # Inside / Outside if base.isInside(edge.Vertexes[0].Point, offset/2, True): offset *= -1 + if Side: + print("inside") + Side[0] = "Inside" # Create new arc edge = Part.ArcOfCircle(Part.Circle(curve.Center, FreeCAD.Vector(0,0,1), curve.Radius+offset), start_angle, end_angle).toShape() @@ -223,12 +229,12 @@ def offsetWire(wire, base, offset, forward): 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