From 0ae6a862db5877c855ffe109c90b60b4d9cd4b42 Mon Sep 17 00:00:00 2001 From: ml Date: Tue, 11 Oct 2016 20:09:17 -0700 Subject: [PATCH] Fixed Group issue on fetching the tool; - added recursive parent traversal to deal with dressups and dressups of dressups ... --- src/Mod/Path/PathScripts/PathUtils.py | 35 +++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathUtils.py b/src/Mod/Path/PathScripts/PathUtils.py index 376711db8..115664a2a 100644 --- a/src/Mod/Path/PathScripts/PathUtils.py +++ b/src/Mod/Path/PathScripts/PathUtils.py @@ -498,13 +498,13 @@ def getLastToolLoad(obj): parent = None while parent is not None: - - sibs = parent.Group - for g in sibs: - if isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool): - lastfound = g - if g == child: - tc = lastfound + if hasattr(parent, 'Group'): + sibs = parent.Group + for g in sibs: + if isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool): + lastfound = g + if g == child: + tc = lastfound if tc is None: try: @@ -533,7 +533,7 @@ def getToolControllers(obj): except: parent = None - if parent is not None: + if parent is not None and hasattr(parent, 'Group'): sibs = parent.Group for g in sibs: if isinstance(g.Proxy, PathScripts.PathLoadTool.LoadTool): @@ -542,19 +542,22 @@ def getToolControllers(obj): -def getTool(obj, number=0): - "retrieves a tool from a hosting object with a tooltable, if any" - for o in obj.InList: - if o.TypeId == "Path::FeatureCompoundPython": - if hasattr(o, "Tooltable"): - return o.Tooltable.getTool(number) - return None - def findParentJob(obj): '''retrieves a parent job object for an operation or other Path object''' for i in obj.InList: if isinstance(i.Proxy, PathScripts.PathJob.ObjectPathJob): return i + if i.TypeId == "Path::FeaturePython": + grandParent = findParentJob(i) + if grandParent is not None: + return grandParent + return None + +def getTool(obj, number=0): + "retrieves a tool from a hosting object with a tooltable, if any" + job = findParentJob(obj) + if job is not None: + return job.Tooltable.getTool(number) return None def GetJobs(jobname = None):