Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/FreeCAD/FreeCAD
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Aug 16, 2016
2 parents ab52518 + 81c5994 commit b20dd3f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Mod/Arch/ArchServer.py
Expand Up @@ -282,12 +282,14 @@ def openFile(self):
FreeCAD.Console.PrintMessage(translate("Arch","Opening file...\n"))
self.form.labelStatus.setText(translate("Arch","Opening file..."))
if not tf:
tf = tempfile.mkstemp(suffix=".ifc")[1]
th,tf = tempfile.mkstemp(suffix=".ifc")
f = open(tf,"wb")
f.write(base64.b64decode(downloaddata))
f.close()
os.close(th)
import importIFC
importIFC.open(tf)
os.remove(tf)
self.form.labelStatus.setText("")

def uploadFile(self):
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/Arch/importIFC.py
Expand Up @@ -923,10 +923,11 @@ def export(exportList,filename):
template = template.replace("$project",FreeCAD.ActiveDocument.Name)
template = template.replace("$filename",filename)
template = template.replace("$timestamp",str(time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime())))
templatefile = tempfile.mkstemp(suffix=".ifc")[1]
templatefilehandle,templatefile = tempfile.mkstemp(suffix=".ifc")
of = pyopen(templatefile,"wb")
of.write(template.encode("utf8"))
of.close()
os.close(templatefilehandle)
global ifcfile, surfstyles, clones, sharedobjects
ifcfile = ifcopenshell.open(templatefile)
history = ifcfile.by_type("IfcOwnerHistory")[0]
Expand Down Expand Up @@ -1280,6 +1281,8 @@ def export(exportList,filename):
if STORE_UID:
# some properties might have been changed
FreeCAD.ActiveDocument.recompute()

os.remove(templatefile)


def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tessellation=1):
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/importIFClegacy.py
Expand Up @@ -691,10 +691,11 @@ def getShape(obj,objid):
try:
if MAKETEMPFILES:
import tempfile
tf = tempfile.mkstemp(suffix=".brp")[1]
th,tf = tempfile.mkstemp(suffix=".brp")
of = pyopen(tf,"wb")
of.write(brep_data)
of.close()
os.close(th)
sh = Part.read(tf)
os.remove(tf)
else:
Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Arch/importSH3D.py
Expand Up @@ -125,10 +125,11 @@ def startElement(self, tag, attributes):
elif tag == "pieceOfFurniture":
name = attributes["name"]
data = self.z.read(attributes["model"])
tf = tempfile.mkstemp(suffix=".obj")[1]
th,tf = tempfile.mkstemp(suffix=".obj")
f = pyopen(tf,"wb")
f.write(data)
f.close()
os.close(th)
m = Mesh.read(tf)
fx = (float(attributes["width"])/100)/m.BoundBox.XLength
fy = (float(attributes["height"])/100)/m.BoundBox.YLength
Expand All @@ -153,10 +154,11 @@ def startElement(self, tag, attributes):
elif tag == "doorOrWindow":
name = attributes["name"]
data = self.z.read(attributes["model"])
tf = tempfile.mkstemp(suffix=".obj")[1]
th,tf = tempfile.mkstemp(suffix=".obj")
f = pyopen(tf,"wb")
f.write(data)
f.close()
os.close(th)
m = Mesh.read(tf)
fx = (float(attributes["width"])/100)/m.BoundBox.XLength
fy = (float(attributes["height"])/100)/m.BoundBox.YLength
Expand Down

0 comments on commit b20dd3f

Please sign in to comment.