diff --git a/src/Mod/Arch/ArchMaterial.py b/src/Mod/Arch/ArchMaterial.py index da2026b195..0096da62a0 100644 --- a/src/Mod/Arch/ArchMaterial.py +++ b/src/Mod/Arch/ArchMaterial.py @@ -250,6 +250,7 @@ class _ArchMaterial: "The Material object" def __init__(self,obj): + self.Type = "Material" obj.Proxy = self obj.addProperty("App::PropertyString","Description","Arch",QT_TRANSLATE_NOOP("App::Property","A description for this material")) @@ -259,7 +260,8 @@ class _ArchMaterial: obj.addProperty("App::PropertyColor","Color","Arch",QT_TRANSLATE_NOOP("App::Property","The color of this material")) def onChanged(self,obj,prop): - d = None + + d = obj.Material if prop == "Material": if "DiffuseColor" in obj.Material: c = tuple([float(f) for f in obj.Material['DiffuseColor'].strip("()").split(",")]) @@ -283,52 +285,51 @@ class _ArchMaterial: if hasattr(obj,"Description"): if obj.Description != obj.Material["Description"]: obj.Description = obj.Material["Description"] + if "Name" in obj.Material: + if hasattr(obj,"Label"): + if obj.Label != obj.Material["Name"]: + obj.Label = obj.Material["Name"] + elif prop == "Label": + if "Name" in d: + if d["Name"] == obj.Label: + return + d["Name"] = obj.Label elif prop == "Color": if hasattr(obj,"Color"): - if obj.Material: - d = obj.Material - val = str(obj.Color[:3]) - if "DiffuseColor" in d: - if d["DiffuseColor"] == val: - return - d["DiffuseColor"] = val + val = str(obj.Color[:3]) + if "DiffuseColor" in d: + if d["DiffuseColor"] == val: + return + d["DiffuseColor"] = val elif prop == "Transparency": if hasattr(obj,"Transparency"): - if obj.Material: - d = obj.Material - val = str(obj.Transparency) - if "Transparency" in d: - if d["Transparency"] == val: - return - d["Transparency"] = val + val = str(obj.Transparency) + if "Transparency" in d: + if d["Transparency"] == val: + return + d["Transparency"] = val elif prop == "ProductURL": if hasattr(obj,"ProductURL"): - if obj.Material: - d = obj.Material - val = obj.ProductURL - if "ProductURL" in d: - if d["ProductURL"] == val: - return - obj.Material["ProductURL"] = val + val = obj.ProductURL + if "ProductURL" in d: + if d["ProductURL"] == val: + return + obj.Material["ProductURL"] = val elif prop == "StandardCode": if hasattr(obj,"StandardCode"): - if obj.Material: - d = obj.Material - val = obj.StandardCode - if "StandardCode" in d: - if d["StandardCode"] == val: - return - d["StandardCode"] = val + val = obj.StandardCode + if "StandardCode" in d: + if d["StandardCode"] == val: + return + d["StandardCode"] = val elif prop == "Description": if hasattr(obj,"Description"): - if obj.Material: - d = obj.Material - val = obj.Description - if "Description" in d: - if d["Description"] == val: - return - d["Description"] = val - if d: + val = obj.Description + if "Description" in d: + if d["Description"] == val: + return + d["Description"] = val + if d and (d != obj.Material): obj.Material = d if FreeCAD.GuiUp: import FreeCADGui