Allow deletion of dressup even if model is not setup correctly.

This commit is contained in:
Markus Lampert
2019-12-31 18:21:39 -08:00
parent edd46bc7d0
commit a0d7174a3d
7 changed files with 31 additions and 20 deletions

View File

@@ -168,10 +168,12 @@ class ViewProviderDressup:
def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True
class CommandPathDressup:

View File

@@ -465,10 +465,12 @@ class ViewProviderDressup:
def onDelete(self, arg1=None, arg2=None):
# pylint: disable=unused-argument
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object.Base)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object.Base)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True

View File

@@ -322,10 +322,12 @@ class ViewProviderDressup:
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
PathLog.debug("Deleting Dressup")
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True
def __getstate__(self):

View File

@@ -66,7 +66,8 @@ class DressupPathBoundary(object):
def onDelete(self, obj, args):
if obj.Base:
job = PathUtils.findParentJob(obj)
job.Proxy.addOperation(obj.Base, obj)
if job:
job.Proxy.addOperation(obj.Base, obj)
if obj.Base.ViewObject:
obj.Base.ViewObject.Visibility = True
obj.Base = None

View File

@@ -191,7 +191,8 @@ class DressupPathBoundaryViewProvider(object):
return [self.obj.Base, self.obj.Stock]
def onDelete(self, vobj, args=None):
vobj.Object.Proxy.onDelete(vobj.Object, args)
if vobj.Object and vobj.Object.Proxy:
vobj.Object.Proxy.onDelete(vobj.Object, args)
return True
def setEdit(self, vobj, mode=0):

View File

@@ -654,10 +654,12 @@ class ViewProviderDressup:
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
PathLog.debug("Deleting Dressup")
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True
def __getstate__(self):

View File

@@ -422,8 +422,9 @@ class PathDressupTagViewProvider:
if self.obj.Base.ViewObject:
self.obj.Base.ViewObject.Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base and job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
# if self.debugDisplay():
# self.vobj.Debug.removeObjectsFromDocument()
# self.vobj.Debug.Document.removeObject(self.vobj.Debug.Name)