CAM: ToggleOperation - Allow for Job and Operations group

This commit is contained in:
tarman3
2025-10-27 07:25:00 +02:00
parent 316cfc3a34
commit 24f11815e5

View File

@@ -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()