Skip to content

Commit

Permalink
Fixed inner circle bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Schildkroet committed Mar 17, 2020
1 parent d586eea commit 301249b
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/Mod/Path/PathScripts/PathDressupLeadInOut.py
Expand Up @@ -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':
Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 301249b

Please sign in to comment.