From 32cb1117211eb43a3c87d35b43c2e300cb6be4fa Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Tue, 29 May 2018 07:18:18 -0700 Subject: [PATCH] Filter out duplicate selections --- src/Mod/Path/PathScripts/PathEngraveGui.py | 28 ++++++++++++++-------- src/Mod/Path/PathScripts/PathOp.py | 15 ++++++------ src/Mod/Path/PathScripts/PathSelection.py | 2 +- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathEngraveGui.py b/src/Mod/Path/PathScripts/PathEngraveGui.py index b227d5568e..ffce6bed30 100644 --- a/src/Mod/Path/PathScripts/PathEngraveGui.py +++ b/src/Mod/Path/PathScripts/PathEngraveGui.py @@ -52,17 +52,25 @@ class TaskPanelBaseGeometryPage(PathOpGui.TaskPanelBaseGeometryPage): return super(TaskPanelBaseGeometryPage, self) def addBaseGeometry(self, selection): - if 1 == len(selection) and selection[0].Object.isDerivedFrom('Part::Part2DObject'): - sel = selection[0] - if sel.HasSubObjects: - for sub in sel.SubElementNames: - self.obj.Proxy.addBase(self.obj, sel.Object, sub) + added = False + shapes = self.obj.BaseShapes + for sel in selection: + if sel.Object in shapes: + PathLog.notice((translate("Path", "Base shape %s already in the list")+"\n") % (sel.Object.Label)) + continue + if sel.Object.isDerivedFrom('Part::Part2DObject'): + if sel.HasSubObjects: + for sub in sel.SubElementNames: + self.obj.Proxy.addBase(self.obj, sel.Object, sub) + else: + shapes.append(sel.Object) + self.obj.BaseShapes = shapes + added = True else: - shapes = self.obj.BaseShapes - shapes.append(sel.Object) - self.obj.BaseShapes = shapes - return True - return self.super().addBaseGeometry(selection) + base = self.super().addBaseGeometry(selection) + added = added or base + + return added def setFields(self, obj): self.super().setFields(obj) diff --git a/src/Mod/Path/PathScripts/PathOp.py b/src/Mod/Path/PathScripts/PathOp.py index 35e4618bdc..356ee42219 100644 --- a/src/Mod/Path/PathScripts/PathOp.py +++ b/src/Mod/Path/PathScripts/PathOp.py @@ -427,7 +427,7 @@ class ObjectOp(object): return result def addBase(self, obj, base, sub): - PathLog.track() + PathLog.track(obj, base, sub) base = PathUtil.getPublicObject(base) if self._setBaseAndStock(obj): @@ -436,10 +436,11 @@ class ObjectOp(object): baselist = obj.Base if baselist is None: baselist = [] - item = (base, sub) - if item in baselist: - PathLog.notice(translate("Path", "This object already in the list")+"\n") - else: - baselist.append(item) - obj.Base = baselist + for p, el in baselist: + if p == base and sub in el: + PathLog.notice((translate("Path", "Base object %s.%s already in the list")+"\n") % (base.Label, sub)) + return + + baselist.append((base, sub)) + obj.Base = baselist diff --git a/src/Mod/Path/PathScripts/PathSelection.py b/src/Mod/Path/PathScripts/PathSelection.py index 1abfb5015d..35b20f34b2 100644 --- a/src/Mod/Path/PathScripts/PathSelection.py +++ b/src/Mod/Path/PathScripts/PathSelection.py @@ -50,7 +50,7 @@ class ENGRAVEGate: except: return False - if shape.BoundBox.ZLength == 0.0 and len(obj.Wires) > 0: + if shape.BoundBox.ZLength == 0.0 and len(shape.Wires) > 0: return True if shape.ShapeType == 'Edge':