From a4fc08087aad367f5c5a083c0e0c175f9f6cff97 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Mon, 26 Feb 2024 09:14:19 +0100 Subject: [PATCH] Assembly: Deactivate other tools when insert part is active. Fixes #12551 --- src/Mod/Assembly/CommandCreateAssembly.py | 3 +++ src/Mod/Assembly/CommandCreateJoint.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Mod/Assembly/CommandCreateAssembly.py b/src/Mod/Assembly/CommandCreateAssembly.py index 4a6e9e34b2..1d498ca8b6 100644 --- a/src/Mod/Assembly/CommandCreateAssembly.py +++ b/src/Mod/Assembly/CommandCreateAssembly.py @@ -55,6 +55,9 @@ class CommandCreateAssembly: } def IsActive(self): + if Gui.Control.activeDialog(): + return False + if Preferences.preferences().GetBool("EnforceOneAssemblyRule", True): activeAssembly = UtilsAssembly.activeAssembly() diff --git a/src/Mod/Assembly/CommandCreateJoint.py b/src/Mod/Assembly/CommandCreateJoint.py index 92462016d5..cbbdf29365 100644 --- a/src/Mod/Assembly/CommandCreateJoint.py +++ b/src/Mod/Assembly/CommandCreateJoint.py @@ -42,8 +42,16 @@ __author__ = "Ondsel" __url__ = "https://www.freecad.org" +def noOtherTaskActive(): + return UtilsAssembly.isAssemblyCommandActive() or JointObject.activeTask is not None + + def isCreateJointActive(): - return UtilsAssembly.isAssemblyGrounded() and UtilsAssembly.assembly_has_at_least_n_parts(2) + return ( + UtilsAssembly.isAssemblyGrounded() + and UtilsAssembly.assembly_has_at_least_n_parts(2) + and noOtherTaskActive() + ) def activateJoint(index): @@ -86,7 +94,7 @@ class CommandCreateJointFixed: if UtilsAssembly.activePart() is not None: return UtilsAssembly.assembly_has_at_least_n_parts(2) - return UtilsAssembly.isAssemblyGrounded() and UtilsAssembly.assembly_has_at_least_n_parts(2) + return isCreateJointActive() def Activated(self): activateJoint(0)