Assembly: Fixed joint should not be active if no part is grounded. Fixes #12544

This commit is contained in:
PaddleStroke
2024-05-06 18:32:00 +02:00
committed by Yorik van Havre
parent bf0146ca86
commit f63abc1cf2
2 changed files with 9 additions and 11 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ class CommandCreateJointFixed:
}
def IsActive(self):
if UtilsAssembly.activePart:
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)
+8 -10
View File
@@ -38,29 +38,27 @@ __author__ = "Ondsel"
__url__ = "https://www.freecad.org"
def activeAssembly():
def activePartOrAssembly():
doc = Gui.ActiveDocument
if doc is None or doc.ActiveView is None:
return None
active_assembly = doc.ActiveView.getActiveObject("part")
return doc.ActiveView.getActiveObject("part")
if active_assembly is not None and active_assembly.Type == "Assembly":
def activeAssembly():
active_assembly = activePartOrAssembly()
if active_assembly is not None and active_assembly.isDerivedFrom("Assembly::AssemblyObject"):
return active_assembly
return None
def activePart():
doc = Gui.ActiveDocument
active_part = activePartOrAssembly()
if doc is None or doc.ActiveView is None:
return None
active_part = doc.ActiveView.getActiveObject("part")
if active_part is not None and active_part.Type != "Assembly":
if active_part is not None and not active_part.isDerivedFrom("Assembly::AssemblyObject"):
return active_part
return None