From 0babf30fddde90408d1e53213314e9ae18440521 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Sun, 18 Oct 2015 21:54:53 +0300 Subject: [PATCH] OnDelete implementations Unhide originals when deleting features that hide originals. Special logic with explode (prevent unhiding), to be able to delete unneeded stuff easily. --- CompoundFilter.py | 15 ++++++++++++++- FuseCompound.py | 7 +++++++ latticeDowngrade.py | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CompoundFilter.py b/CompoundFilter.py index 576d707..549207f 100644 --- a/CompoundFilter.py +++ b/CompoundFilter.py @@ -155,7 +155,9 @@ class _ViewProviderCompoundFilter: def __init__(self,vobj): vobj.Proxy = self - + vobj.addProperty("App::PropertyBool","DontUnhideOnDelete","CompoundFilter","When this object is deleted, Base and Stencil are unhidden. This flag stops it from happening.") + vobj.setEditorMode("DontUnhideOnDelete", 2) # set hidden + def getIcon(self): return getIconPath("Lattice_CompoundFilter.svg") @@ -182,6 +184,16 @@ class _ViewProviderCompoundFilter: children.append(self.Object.Stencil) return children + def onDelete(self, feature, subelements): # subelements is a tuple of strings + if not self.ViewObject.DontUnhideOnDelete: + try: + self.Object.Base.ViewObject.show() + if self.Object.Stencil: + self.Object.Stencil.ViewObject.show() + except Exception as err: + FreeCAD.Console.PrintError("Error in onDelete: " + err.message) + return True + def CreateCompoundFilter(name): sel = FreeCADGui.Selection.getSelection() FreeCAD.ActiveDocument.openTransaction("Create CompoundFilter") @@ -253,6 +265,7 @@ class _CommandExplode: cf.Base = obj cf.FilterType = 'specific items' cf.items = str(i) + cf.ViewObject.DontUnhideOnDelete = True FreeCAD.ActiveDocument.recompute() except Exception: FreeCAD.ActiveDocument.abortTransaction() diff --git a/FuseCompound.py b/FuseCompound.py index 1007e54..a198a58 100644 --- a/FuseCompound.py +++ b/FuseCompound.py @@ -92,6 +92,13 @@ class _ViewProviderFuseCompound: def claimChildren(self): return [self.Object.Base] + + def onDelete(self, feature, subelements): # subelements is a tuple of strings + try: + self.Object.Base.ViewObject.show() + except Exception as err: + FreeCAD.Console.PrintError("Error in onDelete: " + err.message) + return True def CreateFuseCompound(name): FreeCAD.ActiveDocument.openTransaction("Create FuseCompound") diff --git a/latticeDowngrade.py b/latticeDowngrade.py index c1c5fe3..d4dab85 100644 --- a/latticeDowngrade.py +++ b/latticeDowngrade.py @@ -119,6 +119,13 @@ class _ViewProviderLatticeDowngrade: def claimChildren(self): return [self.Object.Base] + def onDelete(self, feature, subelements): # subelements is a tuple of strings + try: + self.Object.Base.ViewObject.show() + except Exception as err: + FreeCAD.Console.PrintError("Error in onDelete: " + err.message) + return True + def CreateLatticeDowngrade(name, mode = "Wires"): FreeCAD.ActiveDocument.openTransaction("Create latticeDowngrade")