From 293868c46b1d0252ce50d822af93236a3968a4ff Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 25 Dec 2021 00:27:19 -0600 Subject: [PATCH] Path: Fix 'NoneType' argument error in '_stepTransitionCmds()' The 'p1' argument is passed in as 'None' on occasion. This fix cancels the efficient transition between the two points. 3D Surface is and experimental op, and therefore this fix needs additional user testing with various complex models. --- src/Mod/Path/PathScripts/PathSurface.py | 71 +++++++++++++------------ 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index bf2107b34c..14df90461d 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -1402,43 +1402,48 @@ class ObjectSurface(PathOp.ObjectOp): maxXYDistanceSqrd = (self.cutter.getDiameter() * 2)**2 if obj.OptimizeStepOverTransitions: - # Short distance within step over - xyDistanceSqrd = ((p1.x - p2.x)**2 + (p1.y - p2.y)**2) - # Try to keep cutting for short distances. - if xyDistanceSqrd <= maxXYDistanceSqrd: - # Try to keep cutting, following the model shape - (transLine, minZ, maxZ) = self._getTransitionLine( - safePDC, p1, p2, obj) - # For now, only optimize moderate deviations in Z direction, and - # no dropping below the min of p1 and p2, primarily for multi - # layer path safety. - zFloor = min(p1.z, p2.z) - if abs(minZ - maxZ) < self.cutter.getDiameter(): - for pt in transLine[1:-1]: + if p1 and p2: + # Short distance within step over + xyDistanceSqrd = ((p1.x - p2.x)**2 + (p1.y - p2.y)**2) + # Try to keep cutting for short distances. + if xyDistanceSqrd <= maxXYDistanceSqrd: + # Try to keep cutting, following the model shape + (transLine, minZ, maxZ) = self._getTransitionLine( + safePDC, p1, p2, obj) + # For now, only optimize moderate deviations in Z direction, and + # no dropping below the min of p1 and p2, primarily for multi + # layer path safety. + zFloor = min(p1.z, p2.z) + if abs(minZ - maxZ) < self.cutter.getDiameter(): + for pt in transLine[1:-1]: + cmds.append( + Path.Command('G1', { + 'X': pt.x, + 'Y': pt.y, + # Enforce zFloor + 'Z': max(pt.z, zFloor), + 'F': self.horizFeed + })) + # Use p2 (start of next step) verbatim cmds.append( Path.Command('G1', { - 'X': pt.x, - 'Y': pt.y, - # Enforce zFloor - 'Z': max(pt.z, zFloor), + 'X': p2.x, + 'Y': p2.y, + 'Z': p2.z, 'F': self.horizFeed })) - # Use p2 (start of next step) verbatim - cmds.append( - Path.Command('G1', { - 'X': p2.x, - 'Y': p2.y, - 'Z': p2.z, - 'F': self.horizFeed - })) - return cmds - # For longer distances or large z deltas, we conservatively lift - # to SafeHeight for lack of an accurate stock model, but then - # speed up the drop back down when using multi pass, dropping - # quickly to *previous* layer depth. - stepDown = obj.StepDown.Value if hasattr(obj, - "StepDown") else 0 - rtpd = min(height, p2.z + stepDown + 2) + return cmds + # For longer distances or large z deltas, we conservatively lift + # to SafeHeight for lack of an accurate stock model, but then + # speed up the drop back down when using multi pass, dropping + # quickly to *previous* layer depth. + stepDown = obj.StepDown.Value if hasattr(obj, + "StepDown") else 0 + rtpd = min(height, p2.z + stepDown + 2) + elif not p1: + PathLog.debug("_stepTransitionCmds() p1 is None") + elif not p2: + PathLog.debug("_stepTransitionCmds() p2 is None") # Create raise, shift, and optional lower commands if height is not False: