From 24f11815e5fec0764e400059bc6c0098157abf32 Mon Sep 17 00:00:00 2001 From: tarman3 Date: Mon, 27 Oct 2025 07:25:00 +0200 Subject: [PATCH] CAM: ToggleOperation - Allow for Job and Operations group --- src/Mod/CAM/PathCommands.py | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Mod/CAM/PathCommands.py b/src/Mod/CAM/PathCommands.py index 5ef99eb0a6..2154b93cdf 100644 --- a/src/Mod/CAM/PathCommands.py +++ b/src/Mod/CAM/PathCommands.py @@ -182,6 +182,14 @@ class _ToggleOperation: if not selection: return False + if len(selection) == 1: + # allows to toggle all operations in Job + sel = selection[0] + if hasattr(sel, "Group") and sel.Name.startswith("Job"): + return True + if hasattr(sel, "Group") and sel.Name.startswith("Operations"): + return True + for sel in selection: baseOp = Path.Dressup.Utils.baseOp(sel) if not hasattr(baseOp, "Active"): @@ -191,9 +199,32 @@ class _ToggleOperation: def Activated(self): selection = FreeCADGui.Selection.getSelection() - for sel in selection: - baseOp = Path.Dressup.Utils.baseOp(sel) - baseOp.Active = not baseOp.Active + if (len(selection) == 1 and hasattr(selection[0], "Group")) and ( + selection[0].Name.startswith("Job") or selection[0].Name.startswith("Operations") + ): + sel = selection[0] + # process all Operations in Job + if sel.Name.startswith("Job"): + selection = sel.Operations.Group + elif sel.Name.startswith("Operations"): + selection = sel.Group + + states = [Path.Dressup.Utils.baseOp(sel).Active for sel in selection] + if all(states) or not any(states): + # all operations in one state (active or inactive) - toggle state + for sel in selection: + baseOp = Path.Dressup.Utils.baseOp(sel) + baseOp.Active = not baseOp.Active + else: + # operations in different states - set Active state + for sel in selection: + baseOp = Path.Dressup.Utils.baseOp(sel) + baseOp.Active = True + + else: + for sel in selection: + baseOp = Path.Dressup.Utils.baseOp(sel) + baseOp.Active = not baseOp.Active FreeCAD.ActiveDocument.recompute()