Material: Fixed the material editor dialog, thanks to rockn

This commit is contained in:
Yorik van Havre
2015-11-24 22:57:50 -02:00
parent 330fb12588
commit faf062dc5a
2 changed files with 62 additions and 67 deletions

View File

@@ -79,6 +79,9 @@ def decode(name):
def read(filename):
"reads a FCMat file and returns a dictionary from it"
if isinstance(filename,unicode):
import sys
filename = filename.encode(sys.getfilesystemencoding())
f = pythonopen(filename)
d = {}
l = 0
@@ -118,16 +121,21 @@ def write(filename,dictionary):
user[k] = i
# write header
rev = FreeCAD.ConfigGet("BuildVersionMajor")+"."+FreeCAD.ConfigGet("BuildVersionMinor")+" "+FreeCAD.ConfigGet("BuildRevision")
filename = filename[0]
if isinstance(filename,unicode):
import sys
filename = filename.encode(sys.getfilesystemencoding())
print filename
f = pythonopen(filename,"wb")
f.write("; " + header["CardName"] + "\n")
f.write("; " + header["AuthorAndLicense"] + "\n")
f.write("; " + header["CardName"].encode("utf8") + "\n")
f.write("; " + header["AuthorAndLicense"].encode("utf8") + "\n")
f.write("; file produced by FreeCAD " + rev + "\n")
f.write("; information about the content of this card can be found here:\n")
f.write("; http://www.freecadweb.org/wiki/index.php?title=Material\n")
f.write("\n")
if header["Source"]:
f.write("; source of the data provided in this card:\n")
f.write("; " + header["Source"] + "\n")
f.write("; " + header["Source"].encode("utf8") + "\n")
f.write("\n")
# write sections
for s in contents: