From 99fc24ea07bd683c2e0be946082fae9ce38a5f34 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 26 Aug 2015 19:24:00 +0200 Subject: [PATCH] + fixes #0002221 --- src/Gui/ApplicationPy.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index b927b05ec..d47badfa6 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -30,6 +30,8 @@ # include # include # include +# include +# include #endif #include @@ -42,7 +44,9 @@ #include "MainWindow.h" #include "EditorView.h" #include "PythonEditor.h" +#include "SoFCDB.h" #include "View3DInventor.h" +#include "ViewProvider.h" #include "WidgetFactory.h" #include "Workbench.h" #include "WorkbenchManager.h" @@ -411,6 +415,34 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /* return 0; } else { + SoSeparator* sep = new SoSeparator(); + sep->ref(); + + for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { + PyObject* item = (*it).ptr(); + if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) { + App::DocumentObject* obj = static_cast(item)->getDocumentObjectPtr(); + + Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj); + if (vp) { + sep->addChild(vp->getRoot()); + } + } + } + + + SoGetPrimitiveCountAction action; + action.setCanApproximate(true); + action.apply(sep); + + bool binary = false; + if (action.getTriangleCount() > 100000 || + action.getPointCount() > 30000 || + action.getLineCount() > 10000) + binary = true; + + SoFCDB::writeToFile(sep, Utf8Name.c_str(), binary); + sep->unref(); } } else if (ext == QLatin1String("pdf")) {