Fixed output of ViewObject attribute in console mode

This commit is contained in:
Yorik van Havre 2014-08-07 10:38:41 -03:00
parent c66de2f8cb
commit e0bdc07c4d

View File

@ -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()));