Skip to content

Commit

Permalink
Path: Fix g-code arc direction
Browse files Browse the repository at this point in the history
Fixed incorrect point orders assigned to g2 and g3 commands.
Add application of `ReverseDirection` property to `ZigZag` cut pattern.
Make default arc direction clockwise(g2) for all cut patterns and layer modes.
Make tool diameter access backward compatible.
  • Loading branch information
Russ4262 committed Nov 23, 2020
1 parent 9f489b5 commit a61aa05
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/Mod/Path/PathScripts/PathSlot.py
Expand Up @@ -549,7 +549,8 @@ def _makeArcGCode(self, obj, p1, p2):
It accepts the operation object and two end points for the path.
It returns the slot gcode for the operation."""
CMDS = list()
PATHS = [(p1, p2, 'G2'), (p2, p1, 'G3')]
PATHS = [(p2, p1, 'G2'), (p1, p2, 'G3')]
path_index = 0

def arcPass(PNTS, depth):
cmds = list()
Expand All @@ -566,25 +567,29 @@ def arcPass(PNTS, depth):
return cmds

if obj.LayerMode == 'Single-pass':
PNTS = PATHS[0]
if obj.ReverseDirection:
PNTS = PATHS[1]
CMDS.extend(arcPass(PNTS, obj.FinalDepth.Value))
path_index = 1
CMDS.extend(arcPass(PATHS[path_index], obj.FinalDepth.Value))
else:
if obj.CutPattern == 'Line':
PNTS = PATHS[0]
if obj.ReverseDirection:
PNTS = PATHS[1]
path_index = 1
for dep in self.depthParams:
CMDS.extend(arcPass(PNTS, dep))
CMDS.extend(arcPass(PATHS[path_index], dep))
CMDS.append(Path.Command('G0', {'Z': obj.SafeHeight.Value, 'F': self.vertRapid}))
elif obj.CutPattern == 'ZigZag':
i = 0
for dep in self.depthParams:
if i % 2.0 == 0: # even
CMDS.extend(arcPass(PATHS[0], dep))
else: # odd
CMDS.extend(arcPass(PATHS[1], dep))
if obj.ReverseDirection:
if i % 2.0 == 0: # even
CMDS.extend(arcPass(PATHS[0], dep))
else: # odd
CMDS.extend(arcPass(PATHS[1], dep))
else:
if i % 2.0 == 0: # even
CMDS.extend(arcPass(PATHS[1], dep))
else: # odd
CMDS.extend(arcPass(PATHS[0], dep))
i += 1
# Raise to SafeHeight when finished
CMDS.append(Path.Command('G0', {'Z': obj.SafeHeight.Value, 'F': self.vertRapid}))
Expand Down Expand Up @@ -1568,7 +1573,10 @@ def _arcCollisionCheck(self, obj, p1, p2, arcCenter, arcRadius):
Make arch face between circles. Fuse and extrude it vertically.
Check for collision with model."""
# Make path travel of tool as 3D solid.
rad = self.tool.Diameter / 2.0
if hasattr(self.tool.Diameter, 'Value'):
rad = self.tool.Diameter.Value / 2.0
else:
rad = self.tool.Diameter / 2.0
extFwd = obj.StartDepth.Value - obj.FinalDepth.Value
extVect = FreeCAD.Vector(0.0, 0.0, extFwd)

Expand Down

0 comments on commit a61aa05

Please sign in to comment.