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

This commit is contained in:
PaddleStroke
2024-02-22 07:55:14 +01:00
committed by Yorik van Havre
parent bf0146ca86
commit f63abc1cf2
2 changed files with 9 additions and 11 deletions

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)

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