From 19926d7beb9031d47c1e330f3217c2a06111f1fd Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Fri, 15 Feb 2019 12:53:53 +0100 Subject: [PATCH] Material, mat card writer, do not write empty sections --- src/Mod/Material/importFCMat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mod/Material/importFCMat.py b/src/Mod/Material/importFCMat.py index 77c3f75624..dcaf3fe890 100644 --- a/src/Mod/Material/importFCMat.py +++ b/src/Mod/Material/importFCMat.py @@ -142,7 +142,7 @@ def write(filename, dictionary): user = contents[-1] for proper in group.getchildren(): properName = proper.attrib['Name'] - contents[-1][properName] = "" + contents[-1][properName] = '' for k, i in dictionary.items(): found = False for group in contents: @@ -152,6 +152,11 @@ def write(filename, dictionary): found = True if not found: user[k] = i + # delete empty properties + for group in contents: + for k in list(group.keys()): # iterating over a dict and changing it is not allowed, thus we iterate over a list of the keys + if group[k] == '': + del group[k] # card writer rev = FreeCAD.ConfigGet("BuildVersionMajor") + "." + FreeCAD.ConfigGet("BuildVersionMinor") + "." + FreeCAD.ConfigGet("BuildRevision")