From fb9ad1609d24d413fa12ca8cd3261ad6adfc9063 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sun, 7 Jan 2018 19:04:16 +0800 Subject: [PATCH] gui: fix assembly solve command Fix selection detection, and undo/redo setup --- assembly.py | 4 ++-- gui.py | 2 ++ solver.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/assembly.py b/assembly.py index 51d0089..d4efb09 100644 --- a/assembly.py +++ b/assembly.py @@ -1463,9 +1463,9 @@ class Assembly(AsmGroup): objs.add(sel.Object) continue for subname in sel.SubElementNames: - ret = Assembly.find(sel.Object,subname,recursive=True) + ret = Assembly.find(sel.Object,subname,keepEmptyChild=True) if ret: - objs.add(ret[-1].Assembly) + objs.add(ret.Assembly) return tuple(objs) @staticmethod diff --git a/gui.py b/gui.py index 4cf6a92..915c9cf 100644 --- a/gui.py +++ b/gui.py @@ -138,8 +138,10 @@ class AsmCmdSolve(AsmCmdBase): @classmethod def Activated(cls): from . import solver + FreeCAD.setActiveTransaction('Assembly solve') logger.report('command "{}" exception'.format(cls.getName()), solver.solve) + FreeCAD.closeActiveTransaction() class AsmCmdMove(AsmCmdBase): diff --git a/solver.py b/solver.py index 093e50e..bdd0704 100644 --- a/solver.py +++ b/solver.py @@ -155,8 +155,8 @@ def _solve(objs=None,recursive=None,reportFailed=True, raise RuntimeError('No assembly found in selection') else: objs = FreeCAD.ActiveDocument.Objects - if recursive is None: - recursive = True + if recursive is None: + recursive = True elif not isinstance(objs,(list,tuple)): objs = [objs]