From 301249bd859e37766ccf886c71bd22d8c34101e5 Mon Sep 17 00:00:00 2001 From: Patrick Felixberger Date: Tue, 17 Mar 2020 21:24:37 +0100 Subject: [PATCH] Fixed inner circle bug --- .../Path/PathScripts/PathDressupLeadInOut.py | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 0a9bd80d7af2..4417be654dfc 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -166,6 +166,7 @@ def getLeadStart(self, obj, queue, action): horizFeed = tc.HorizFeed.Value vertFeed = tc.VertFeed.Value toolnummer = tc.ToolNumber + arcs_identical = False # Set the correct twist command if self.getDirectionOfPath(obj) == 'left': @@ -183,6 +184,7 @@ def getLeadStart(self, obj, queue, action): p0 = queue[0].Placement.Base p1 = queue[1].Placement.Base v = self.normalize(p1.sub(p0)) + #arcdir = queue[1].Name # PathLog.debug(" CURRENT_IN ARC : P0 X:{} Y:{} P1 X:{} Y:{} ".format(p0.x,p0.y,p1.x,p1.y)) # Calculate offset vector (will be overwritten for arcs) @@ -206,32 +208,43 @@ def getLeadStart(self, obj, queue, action): pij.x += queue[1].Parameters['I'] pij.y += queue[1].Parameters['J'] + if arcdir == queue[1].Name: + arcs_identical = True + # Calculate vector circle start -> circle middle vec_circ = pij.sub(p0) - + print("Vec:circ: {}".format(vec_circ)) # Rotate vector to get direction for lead in if arcdir == "G2": vec_rot = self.rotate(vec_circ, 90) else: vec_rot = self.rotate(vec_circ, -90) - + print("Vec:rot: {}".format(vec_rot)) # Normalize and invert vector vec_n = self.normalize(vec_rot) v = self.invert(vec_n) + #v = vec_n + print("Vec:inv: {}".format(v)) # Calculate offset of lead in if arcdir == "G3": off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) else: off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) - + print("Vec:off: {}".format(off_v)) # Multiply offset by LeadIn length - vec_off = self.multiply(vec_rot, obj.ExtendLeadIn) + vec_off = self.multiply(vec_n, obj.ExtendLeadIn) offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0) # IJ + print("off: {}".format(offsetvector)) if obj.RadiusCenter == 'Radius': leadstart = (p0.add(off_v)).sub(offsetvector) # Rmode + if arcs_identical: + t = p0.sub(leadstart) + t = p0.add(t) + leadstart = t + offsetvector = self.multiply(offsetvector, -1) else: leadstart = p0.add(off_v) # Dmode @@ -286,6 +299,7 @@ def getLeadEnd(self, obj, queue, action): results = [] horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value R = obj.Length.Value # Radius of roll or length + arcs_identical = False # set the correct twist command if self.getDirectionOfPath(obj) == 'right': @@ -322,6 +336,9 @@ def getLeadEnd(self, obj, queue, action): pij.y += queue[1].Parameters['J'] ve = pij.sub(p1) + if arcdir == queue[1].Name: + arcs_identical = True + if arcdir == "G2": vec_rot = self.rotate(ve, -90) else: @@ -342,6 +359,11 @@ def getLeadEnd(self, obj, queue, action): offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0.0) if obj.RadiusCenter == 'Radius': leadend = (p1.add(off_v)).add(offsetvector) # Rmode + if arcs_identical: + t = p1.sub(leadend) + t = p1.add(t) + leadend = t + off_v = self.multiply(off_v, -1) else: leadend = p1.add(off_v) # Dmode @@ -496,8 +518,8 @@ def generateLeadInOutCurve(self, obj): for cmd in layer: #print("CurLoc: {}, NewCmd: {}".format(currLocation, cmd)) - if currLocation['X'] == cmd.x and currLocation['Y'] == cmd.y and currLocation['Z'] == cmd.z and cmd.Name in ['G1', 'G01']: - continue + #if currLocation['X'] == cmd.x and currLocation['Y'] == cmd.y and currLocation['Z'] == cmd.z and cmd.Name in ['G1', 'G01']: + #continue newpath.append(cmd) if obj.LeadOut: