From 09ef1e9ca952d09f8661e0e736faa06f6bebb298 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 4 Feb 2017 15:40:41 +0100 Subject: [PATCH] undo removal of function caused by PR494 --- src/Mod/Path/PathCommands.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Mod/Path/PathCommands.py b/src/Mod/Path/PathCommands.py index 95618b0b1..e44b81690 100644 --- a/src/Mod/Path/PathCommands.py +++ b/src/Mod/Path/PathCommands.py @@ -78,3 +78,27 @@ class _CommandSelectLoop: if FreeCAD.GuiUp: FreeCADGui.addCommand('Path_SelectLoop',_CommandSelectLoop()) + +def findShape(shape,subname=None,subtype=None): + '''To find a higher oder shape containing the subshape with subname. + E.g. to find the wire containing 'Edge1' in shape, + findShape(shape,'Edge1','Wires') + ''' + if not subname: + return shape + ret = shape.getElement(subname) + if not subtype or not ret or ret.isNull(): + return ret; + if subname.startswith('Face'): + tp = 'Faces' + elif subname.startswith('Edge'): + tp = 'Edges' + elif subname.startswith('Vertex'): + tp = 'Vertex' + else: + return ret + for obj in getattr(shape,subtype): + for sobj in getattr(obj,tp): + if sobj.isEqual(ret): + return obj + return ret