+ disable SVG and IDTF export for 3d view
This commit is contained in:
parent
99fc24ea07
commit
a801fb20b8
|
@ -399,71 +399,62 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the view that belongs to the found document
|
QString fileName = QString::fromUtf8(Utf8Name.c_str());
|
||||||
if (doc) {
|
QFileInfo fi;
|
||||||
QString fileName = QString::fromUtf8(Utf8Name.c_str());
|
fi.setFile(fileName);
|
||||||
QFileInfo fi;
|
QString ext = fi.suffix().toLower();
|
||||||
fi.setFile(fileName);
|
if (ext == QLatin1String("iv") || ext == QLatin1String("wrl") ||
|
||||||
QString ext = fi.suffix().toLower();
|
ext == QLatin1String("vrml") || ext == QLatin1String("wrz")) {
|
||||||
if (ext == QLatin1String("iv") || ext == QLatin1String("wrl") ||
|
|
||||||
ext == QLatin1String("vrml") || ext == QLatin1String("wrz") ||
|
|
||||||
ext == QLatin1String("svg") || ext == QLatin1String("idtf")) {
|
|
||||||
Gui::Document* gui_doc = Application::Instance->getDocument(doc);
|
|
||||||
std::list<MDIView*> view3d = gui_doc->getMDIViewsOfType(View3DInventor::getClassTypeId());
|
|
||||||
if (view3d.empty()) {
|
|
||||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot export to SVG because document doesn't have a 3d view");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SoSeparator* sep = new SoSeparator();
|
|
||||||
sep->ref();
|
|
||||||
|
|
||||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
// build up the graph
|
||||||
PyObject* item = (*it).ptr();
|
SoSeparator* sep = new SoSeparator();
|
||||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
sep->ref();
|
||||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
|
||||||
|
|
||||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
|
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||||
if (vp) {
|
PyObject* item = (*it).ptr();
|
||||||
sep->addChild(vp->getRoot());
|
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||||
}
|
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
|
||||||
SoGetPrimitiveCountAction action;
|
if (vp) {
|
||||||
action.setCanApproximate(true);
|
sep->addChild(vp->getRoot());
|
||||||
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")) {
|
|
||||||
Gui::Document* gui_doc = Application::Instance->getDocument(doc);
|
|
||||||
if (gui_doc) {
|
|
||||||
Gui::MDIView* view = gui_doc->getActiveView();
|
|
||||||
if (view) {
|
|
||||||
View3DInventor* view3d = qobject_cast<View3DInventor*>(view);
|
|
||||||
if (view3d)
|
|
||||||
view3d->viewAll();
|
|
||||||
QPrinter printer(QPrinter::ScreenResolution);
|
|
||||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
|
||||||
printer.setOutputFileName(fileName);
|
|
||||||
view->print(&printer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData());
|
|
||||||
|
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")) {
|
||||||
|
// get the view that belongs to the found document
|
||||||
|
Gui::Document* gui_doc = Application::Instance->getDocument(doc);
|
||||||
|
if (gui_doc) {
|
||||||
|
Gui::MDIView* view = gui_doc->getActiveView();
|
||||||
|
if (view) {
|
||||||
|
View3DInventor* view3d = qobject_cast<View3DInventor*>(view);
|
||||||
|
if (view3d)
|
||||||
|
view3d->viewAll();
|
||||||
|
QPrinter printer(QPrinter::ScreenResolution);
|
||||||
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||||
|
printer.setOutputFileName(fileName);
|
||||||
|
view->print(&printer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData());
|
||||||
|
}
|
||||||
} PY_CATCH;
|
} PY_CATCH;
|
||||||
|
|
||||||
Py_Return;
|
Py_Return;
|
||||||
|
|
|
@ -143,7 +143,7 @@ FreeCAD.addImportType("Python (*.py *.FCMacro *.FCScript)","FreeCADGui")
|
||||||
FreeCAD.addExportType("Inventor V2.1 (*.iv)","FreeCADGui")
|
FreeCAD.addExportType("Inventor V2.1 (*.iv)","FreeCADGui")
|
||||||
FreeCAD.addExportType("VRML V2.0 (*.wrl *.vrml *.wrz *.wrl.gz)","FreeCADGui")
|
FreeCAD.addExportType("VRML V2.0 (*.wrl *.vrml *.wrz *.wrl.gz)","FreeCADGui")
|
||||||
#FreeCAD.addExportType("IDTF (for 3D PDF) (*.idtf)","FreeCADGui")
|
#FreeCAD.addExportType("IDTF (for 3D PDF) (*.idtf)","FreeCADGui")
|
||||||
FreeCAD.addExportType("3D View (*.svg)","FreeCADGui")
|
#FreeCAD.addExportType("3D View (*.svg)","FreeCADGui")
|
||||||
FreeCAD.addExportType("Portable Document Format (*.pdf)","FreeCADGui")
|
FreeCAD.addExportType("Portable Document Format (*.pdf)","FreeCADGui")
|
||||||
|
|
||||||
del(InitApplications)
|
del(InitApplications)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user