Skip to content

Commit

Permalink
+ fixes #2221
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Aug 26, 2015
1 parent 84a65a5 commit 99fc24e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Gui/ApplicationPy.cpp
Expand Up @@ -30,6 +30,8 @@
# include <QPrinter>
# include <QFileInfo>
# include <Inventor/SoInput.h>
# include <Inventor/actions/SoGetPrimitiveCountAction.h>
# include <Inventor/nodes/SoSeparator.h>
#endif

#include <xercesc/util/XMLString.hpp>
Expand All @@ -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"
Expand Down Expand Up @@ -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<App::DocumentObjectPy*>(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")) {
Expand Down

0 comments on commit 99fc24e

Please sign in to comment.