From 82b16a934ce057dc626be9641c3c87b05e2e0445 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 3 Apr 2019 15:15:33 +0200 Subject: [PATCH] workaround in case SoInput.setBuffer raises an exception --- src/Mod/TemplatePyMod/Automation.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mod/TemplatePyMod/Automation.py b/src/Mod/TemplatePyMod/Automation.py index 0b70e50854..8a990d08f7 100644 --- a/src/Mod/TemplatePyMod/Automation.py +++ b/src/Mod/TemplatePyMod/Automation.py @@ -8,6 +8,8 @@ FreeCADCmd -P 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)