From 4284e437d3d4ca4edf1c03e1caa0495df8b8e44f Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 29 Dec 2016 20:42:30 -0200 Subject: [PATCH] Arch: Make sure the BaseMaterial property contains a Material object --- src/Mod/Arch/ArchComponent.py | 7 ++++++- src/Mod/Arch/ArchEquipment.py | 1 + src/Mod/Arch/ArchSpace.py | 1 + src/Mod/Arch/ArchStructure.py | 1 + src/Mod/Arch/ArchWindow.py | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index 626427472f..0a9bbc0713 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -346,7 +346,12 @@ class Component: self.Type = state def onChanged(self,obj,prop): - pass + if prop == "BaseMaterial": + if hasattr(obj,"BaseMaterial"): + if obj.BaseMaterial: + if Draft.getType(obj.BaseMaterial) != "Material": + obj.BaseMaterial = None + print "Removing bad BaseMaterial link in ",obj.Name def clone(self,obj): "if this object is a clone, sets the shape. Returns True if this is the case" diff --git a/src/Mod/Arch/ArchEquipment.py b/src/Mod/Arch/ArchEquipment.py index 39678dff7b..b24888bb08 100644 --- a/src/Mod/Arch/ArchEquipment.py +++ b/src/Mod/Arch/ArchEquipment.py @@ -261,6 +261,7 @@ class _Equipment(ArchComponent.Component): def onChanged(self,obj,prop): self.hideSubobjects(obj,prop) + ArchComponent.Component.onChanged(self,obj.prop) def execute(self,obj): diff --git a/src/Mod/Arch/ArchSpace.py b/src/Mod/Arch/ArchSpace.py index 433225d606..933b220faf 100644 --- a/src/Mod/Arch/ArchSpace.py +++ b/src/Mod/Arch/ArchSpace.py @@ -290,6 +290,7 @@ class _Space(ArchComponent.Component): obj.EquipmentPower = p if hasattr(obj,"Area"): obj.setEditorMode('Area',1) + ArchComponent.Component.onChanged(self,obj.prop) def addSubobjects(self,obj,subobjects): "adds subobjects to this space" diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index cbc73aca53..98dc7a3c34 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -577,6 +577,7 @@ class _Structure(ArchComponent.Component): if nodes: self.nodes = [v.Point.add(offset) for v in nodes.Vertexes] obj.Nodes = self.nodes + ArchComponent.Component.onChanged(self,obj.prop) def getNodeEdges(self,obj): "returns a list of edges from stuctural nodes" diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index 4fe32ac025..5b20a950d7 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -688,6 +688,7 @@ class _Window(ArchComponent.Component): # because of load order, but it doesn't harm... pass FreeCAD.ActiveDocument.recompute() + ArchComponent.Component.onChanged(self,obj.prop) def execute(self,obj):