Skip to content

Commit

Permalink
Arch: Fixed encoding in filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jul 22, 2015
1 parent dff298c commit 34f1450
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -253,8 +253,11 @@ def explore(filename=None):

def open(filename,skip=[],only=[],root=None):
"opens an IFC file in a new document"

docname = os.path.splitext(os.path.basename(filename))[0]
if isinstance(docname,unicode):
import sys #workaround since newDocument currently can't handle unicode filenames
docname = docname.encode(sys.getfilesystemencoding())
doc = FreeCAD.newDocument(docname)
doc.Label = docname
doc = insert(filename,doc.Name,skip,only,root)
Expand Down Expand Up @@ -666,10 +669,6 @@ def export(exportList,filename):
except:
FreeCAD.Console.PrintError("IfcOpenShell was not found on this system. IFC support is disabled\n")
return

if isinstance(filename,unicode):
import sys #workaround since ifcopenshell currently can't handle unicode filenames
filename = filename.encode(sys.getfilesystemencoding())

version = FreeCAD.Version()
owner = FreeCAD.ActiveDocument.CreatedBy
Expand All @@ -690,7 +689,7 @@ def export(exportList,filename):
ifctemplate = ifctemplate.replace("$timestamp",str(time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime())))
template = tempfile.mkstemp(suffix=".ifc")[1]
of = pyopen(template,"wb")
of.write(ifctemplate)
of.write(ifctemplate.encode("utf8"))
of.close()
global ifcfile, surfstyles
ifcfile = ifcopenshell.open(template)
Expand Down Expand Up @@ -877,6 +876,11 @@ def export(exportList,filename):
ifcfile.createIfcRelAssociatesMaterial(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'MaterialLink','',relobjs,mat)

if DEBUG: print "writing ",filename,"..."

if isinstance(filename,unicode):
import sys #workaround since ifcopenshell currently can't handle unicode filenames
filename = filename.encode(sys.getfilesystemencoding())

ifcfile.write(filename)


Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Draft/importDXF.py
Expand Up @@ -1467,6 +1467,9 @@ def open(filename):
readPreferences()
if dxfReader:
docname = os.path.splitext(os.path.basename(filename))[0]
if isinstance(docname,unicode):
import sys #workaround since newDocument currently can't handle unicode filenames
docname = docname.encode(sys.getfilesystemencoding())
doc = FreeCAD.newDocument(docname)
doc.Label = decodeName(docname)
processdxf(doc,filename)
Expand Down

0 comments on commit 34f1450

Please sign in to comment.