Extend python interface for groups and fix test cases

This commit is contained in:
Stefan Tröger
2017-02-12 09:01:22 +01:00
committed by wmayer
parent eb601df236
commit f9200f4502
8 changed files with 178 additions and 105 deletions

View File

@@ -25,6 +25,8 @@
#include "DocumentObject.h"
#include "Document.h"
#include "Expression.h"
#include "GroupExtension.h"
#include "GeoFeatureGroupExtension.h"
// inclusion of the generated files (generated out of DocumentObjectPy.xml)
#include <App/DocumentObjectPy.h>
@@ -315,6 +317,42 @@ PyObject* DocumentObjectPy::recompute(PyObject *args)
}
}
PyObject* DocumentObjectPy::getParentGroup(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
try {
auto grp = GroupExtension::getGroupOfObject(getDocumentObjectPtr());
if(!grp) {
Py_INCREF(Py_None);
return Py_None;
}
return grp->getPyObject();
}
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
}
PyObject* DocumentObjectPy::getParentGeoFeatureGroup(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
try {
auto grp = GeoFeatureGroupExtension::getGroupOfObject(getDocumentObjectPtr());
if(!grp) {
Py_INCREF(Py_None);
return Py_None;
}
return grp->getPyObject();
}
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
}
PyObject *DocumentObjectPy::getCustomAttributes(const char* attr) const
{
// search for dynamic property