workaround in case SoInput.setBuffer raises an exception

This commit is contained in:
wmayer
2019-04-03 15:15:33 +02:00
parent 267dcf3965
commit 82b16a934c

View File

@@ -8,6 +8,8 @@ FreeCADCmd -P <path_to_file> Automation.py
"""
import FreeCAD, Part
import os
import tempfile
def makeSnapshotWithGui():
from PySide import QtGui
@@ -48,7 +50,15 @@ def makeSnapshotWithoutGui():
# load it into a buffer
inp=coin.SoInput()
inp.setBuffer(iv)
try:
inp.setBuffer(iv)
except:
tempPath = tempfile.gettempdir()
fileName = tempPath + os.sep + "cone.iv"
file = open(fileName, "w")
file.write(iv)
file.close()
inp.openFile(fileName)
# and create a scenegraph
data = coin.SoDB.readAll(inp)