Create clone for stock and go to some lengths to enforce that.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -23,6 +23,7 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import ArchPanel
|
||||
import Draft
|
||||
import FreeCAD
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathToolController as PathToolController
|
||||
@@ -104,12 +105,46 @@ class ObjectJob:
|
||||
FreeCAD.ActiveDocument.removeObject(obj.Operations.Name)
|
||||
obj.Operations = None
|
||||
|
||||
def isResourceClone(self, obj, propName, resourceName):
|
||||
if hasattr(obj, propName):
|
||||
prop = getattr(obj, propName)
|
||||
if hasattr(prop, 'PathResource') and resourceName == getattr(prop, 'PathResource'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def fixupResourceClone(self, obj, name):
|
||||
if not self.isResourceClone(obj, name, name):
|
||||
orig = getattr(obj, name)
|
||||
if orig:
|
||||
clone = Draft.clone(orig)
|
||||
clone.Label = name
|
||||
clone.addProperty('App::PropertyString', 'PathResource')
|
||||
clone.PathResource = name
|
||||
setattr(obj, name, clone)
|
||||
|
||||
def onBeforeChange(self, obj, prop):
|
||||
PathLog.track(obj.Label, prop)
|
||||
if prop == 'Base' and obj.Base and hasattr(obj.Base, 'PathResource'):
|
||||
PathLog.info('removing old base clone')
|
||||
obj.Base.removeProperty('PathResource')
|
||||
obj.Document.removeObject(obj.Base.Name)
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
PathLog.track(obj.Label, prop)
|
||||
if prop == "PostProcessor" and obj.PostProcessor:
|
||||
processor = PostProcessor.load(obj.PostProcessor)
|
||||
self.tooltip = processor.tooltip
|
||||
self.tooltipArgs = processor.tooltipArgs
|
||||
|
||||
if prop == 'Base':
|
||||
self.fixupResourceClone(obj, 'Base')
|
||||
if prop == 'Stock':
|
||||
self.fixupResourceClone(obj, 'Stock')
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
self.fixupResourceClone(obj, 'Base')
|
||||
self.fixupResourceClone(obj, 'Stock')
|
||||
|
||||
def assignTemplate(self, obj, template):
|
||||
'''assignTemplate(obj, template) ... extract the properties from the given template file and assign to receiver.
|
||||
This will also create any TCs stored in the template.'''
|
||||
|
||||
@@ -83,6 +83,10 @@ class ViewProvider:
|
||||
def claimChildren(self):
|
||||
children = self.obj.ToolController
|
||||
children.append(self.obj.Operations)
|
||||
if self.obj.Base:
|
||||
children.append(self.obj.Base)
|
||||
if self.obj.Stock:
|
||||
children.append(self.obj.Stock)
|
||||
return children
|
||||
|
||||
class TaskPanel:
|
||||
|
||||
Reference in New Issue
Block a user