+ disable SVG and IDTF export for 3d view

This commit is contained in:
wmayer 2015-08-26 22:11:53 +02:00
parent 99fc24ea07
commit a801fb20b8
2 changed files with 49 additions and 58 deletions

View File

@ -399,22 +399,14 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /*
} }
} }
// get the view that belongs to the found document
if (doc) {
QString fileName = QString::fromUtf8(Utf8Name.c_str()); QString fileName = QString::fromUtf8(Utf8Name.c_str());
QFileInfo fi; QFileInfo fi;
fi.setFile(fileName); fi.setFile(fileName);
QString ext = fi.suffix().toLower(); QString ext = fi.suffix().toLower();
if (ext == QLatin1String("iv") || ext == QLatin1String("wrl") || if (ext == QLatin1String("iv") || ext == QLatin1String("wrl") ||
ext == QLatin1String("vrml") || ext == QLatin1String("wrz") || ext == QLatin1String("vrml") || ext == QLatin1String("wrz")) {
ext == QLatin1String("svg") || ext == QLatin1String("idtf")) {
Gui::Document* gui_doc = Application::Instance->getDocument(doc); // build up the graph
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(); SoSeparator* sep = new SoSeparator();
sep->ref(); sep->ref();
@ -444,8 +436,8 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /*
SoFCDB::writeToFile(sep, Utf8Name.c_str(), binary); SoFCDB::writeToFile(sep, Utf8Name.c_str(), binary);
sep->unref(); sep->unref();
} }
}
else if (ext == QLatin1String("pdf")) { else if (ext == QLatin1String("pdf")) {
// get the view that belongs to the found document
Gui::Document* gui_doc = Application::Instance->getDocument(doc); Gui::Document* gui_doc = Application::Instance->getDocument(doc);
if (gui_doc) { if (gui_doc) {
Gui::MDIView* view = gui_doc->getActiveView(); Gui::MDIView* view = gui_doc->getActiveView();
@ -463,7 +455,6 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /*
else { else {
Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData()); Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData());
} }
}
} PY_CATCH; } PY_CATCH;
Py_Return; Py_Return;

View File

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