Expose merge project function to python

This commit is contained in:
wmayer
2012-05-23 15:03:48 +02:00
parent a077d4f178
commit e499e33444
3 changed files with 22 additions and 3 deletions

View File

@@ -32,6 +32,7 @@
#include <App/Document.h>
#include "Document.h"
#include "MergeDocuments.h"
#include "ViewProviderExtern.h"
// inclusion of the generated files (generated out of DocumentPy.xml)
@@ -234,6 +235,22 @@ PyObject* DocumentPy::sendMsgToViews(PyObject *args)
} PY_CATCH;
}
PyObject* DocumentPy::mergeProject(PyObject *args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename)) // convert args: Python->C
return NULL; // NULL triggers exception
PY_TRY {
Base::FileInfo fi(filename);
Base::ifstream str(fi, std::ios::in | std::ios::binary);
App::Document* doc = getDocumentPtr()->getDocument();
MergeDocuments md(doc);
md.importObjects(str);
Py_Return;
} PY_CATCH;
}
Py::Object DocumentPy::getActiveObject(void) const
{
App::DocumentObject *object = getDocumentPtr()->getDocument()->getActiveObject();