From e0bdc07c4dc64c76c6427fb8d78a32a1d038cfa7 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 7 Aug 2014 10:38:41 -0300 Subject: [PATCH] Fixed output of ViewObject attribute in console mode --- src/App/DocumentObjectPyImp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index c8d490c2f..902493e36 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -98,6 +98,10 @@ Py::Object DocumentObjectPy::getViewObject(void) const { try { Py::Module module(PyImport_ImportModule("FreeCADGui"),true); + if (!module.hasAttr("getDocument")) { + // in v0.14+, the GUI module can be loaded in console mode (but doesn't have all its document methods) + return Py::None(); + } Py::Callable method(module.getAttr("getDocument")); Py::Tuple arg(1); arg.setItem(0, Py::String(getDocumentObjectPtr()->getDocument()->getName()));