From ee1b3082c4e8e06957a48676f2a68b7f78f4fc09 Mon Sep 17 00:00:00 2001 From: papaathome <6624189+papaathome@users.noreply.github.com> Date: Wed, 4 Jun 2025 09:50:02 +0200 Subject: [PATCH 1/2] CAM: Update PathUtils.py Proposed fix for `CAM: 3Dsurface, rotational path, difference between X/A and Y/B paths #21556` --- src/Mod/CAM/PathScripts/PathUtils.py | 38 ++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Mod/CAM/PathScripts/PathUtils.py b/src/Mod/CAM/PathScripts/PathUtils.py index 10a846456c..af7481ff04 100644 --- a/src/Mod/CAM/PathScripts/PathUtils.py +++ b/src/Mod/CAM/PathScripts/PathUtils.py @@ -829,9 +829,14 @@ def getPathWithPlacement(pathobj): to the obj's path """ - if not hasattr(pathobj, "Placement") or pathobj.Path is None: + if pathobj.Path is None: return pathobj.Path + # check for no placement or placement POS=(0,0,0), Yaw-Pitch-Roll=(0,0,0) + # isIdentity() returns True if the placement has no displacement and no rotation + if not hasattr(pathobj, "Placement") or pathobj.Placement.isIdentity(): + return pathobj.Path. + return applyPlacementToPath(pathobj.Placement, pathobj.Path) @@ -852,6 +857,15 @@ def applyPlacementToPath(placement, path): currX = 0 currY = 0 currZ = 0 + + # Angles of rotation (on A, B or C) do not need translation but may need a correction on start position, get transformed angles of 0 deg. + cmd = Path.Command("G0 A0 B0 C0") + t = cmd.transform(placement) + tparams = t.Parameters + transA0 = tparams.get("A", 0) + transB0 = tparams.get("B", 0) + transC0 = tparams.get("C", 0) + for cmd in path.Commands: if (cmd.Name in CmdMoveRapid) or (cmd.Name in CmdMove) or (cmd.Name in CmdDrill): params = cmd.Parameters @@ -881,7 +895,27 @@ def applyPlacementToPath(placement, path): params.update({"J": j}) cmd.Parameters = params - commands.append(cmd.transform(placement)) + + # Angles of rotation (on A, B or C) do not need translation, find values before translation. + params = cmd.Parameters + aVal = params.get("A", None) + bVal = params.get("B", None) + cVal = params.get("C", None) + + t = cmd.transform(placement) + + # Set angles of rotation on A, B or C corrected for the transformed angle of 0 deg.. + tparams = t.Parameters + if aVal is not None: + tparams.update({"A": transA0 + aVal}) + if bVal is not None: + tparams.update({"B": transB0 + bVal}) + if cVal is not None: + tparams.update({"C": transC0 + cVal}) + if aVal is not None or bVal is not None or cVal is not None: + t.Parameters = tparams + + commands.append(t) newPath = Path.Path(commands) return newPath From 7d29f4fd628c4bb3aa6855c6fc346e5048da6cf8 Mon Sep 17 00:00:00 2001 From: papaathome <6624189+papaathome@users.noreply.github.com> Date: Wed, 4 Jun 2025 17:28:46 +0200 Subject: [PATCH 2/2] Update PathUtils.py Removed typo ('.') at line 838 --- src/Mod/CAM/PathScripts/PathUtils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/CAM/PathScripts/PathUtils.py b/src/Mod/CAM/PathScripts/PathUtils.py index af7481ff04..478493aa1e 100644 --- a/src/Mod/CAM/PathScripts/PathUtils.py +++ b/src/Mod/CAM/PathScripts/PathUtils.py @@ -835,7 +835,7 @@ def getPathWithPlacement(pathobj): # check for no placement or placement POS=(0,0,0), Yaw-Pitch-Roll=(0,0,0) # isIdentity() returns True if the placement has no displacement and no rotation if not hasattr(pathobj, "Placement") or pathobj.Placement.isIdentity(): - return pathobj.Path. + return pathobj.Path return applyPlacementToPath(pathobj.Placement, pathobj.Path)