Material: Editor and import, only use mat keys if they have a value

This commit is contained in:
Bernd Hahnebach
2018-06-01 08:21:31 +02:00
parent 2deeca9602
commit d114685107
2 changed files with 7 additions and 2 deletions

View File

@@ -235,7 +235,11 @@ class MaterialEditor:
for i2 in range(w.childCount()):
c = w.child(i2)
# TODO the following should be translated back to english,since text(0) could be translated
d[self.collapseKey(str(c.text(0)))] = unicode(c.text(1))
matkey = self.collapseKey(str(c.text(0)))
matvalue = unicode(c.text(1))
if matvalue or (matkey == 'Name'):
# use only keys which are not empty and the name even if empty
d[matkey] = matvalue
return d

View File

@@ -144,7 +144,8 @@ def write(filename,dictionary):
# if the section has no contents, we don't write it
f.write("[" + s["keyname"] + "]\n")
for k,i in s.iteritems():
if k != "keyname":
if (k != "keyname" and i != '') or k == "Name":
# use only keys which are not empty and the name even if empty
f.write(k + "=" + i.encode('utf-8') + "\n")
f.write("\n")
f.close()