Toggle active state of all path operations in selection

Changes "Toggle the Active State of the Operation" from only being
able to toggle one operation. To toggle all operations in a selection.
The toggle command will only be enabled if all selected objects can
be toggled.
This commit is contained in:
Mikael Ågren
2020-04-20 20:35:00 +02:00
parent e8e67e8c5e
commit 477f0c913c

View File

@@ -141,14 +141,16 @@ class _ToggleOperation:
if bool(FreeCADGui.Selection.getSelection()) is False:
return False
try:
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
return isinstance(PathScripts.PathDressup.baseOp(obj).Proxy, PathScripts.PathOp.ObjectOp)
for sel in FreeCADGui.Selection.getSelectionEx():
if not isinstance(PathScripts.PathDressup.baseOp(sel.Object).Proxy, PathScripts.PathOp.ObjectOp):
return False
return True
except(IndexError, AttributeError):
return False
def Activated(self):
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
PathScripts.PathDressup.baseOp(obj).Active = not(PathScripts.PathDressup.baseOp(obj).Active)
for sel in FreeCADGui.Selection.getSelectionEx():
PathScripts.PathDressup.baseOp(sel.Object).Active = not(PathScripts.PathDressup.baseOp(sel.Object).Active)
FreeCAD.ActiveDocument.recompute()