diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp
index b4b99fa4ab..677f8b3e24 100644
--- a/src/App/DocumentObjectPyImp.cpp
+++ b/src/App/DocumentObjectPyImp.cpp
@@ -257,13 +257,42 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args)
}
-PyObject *DocumentObjectPy::getCustomAttributes(const char* /*attr*/) const
+PyObject *DocumentObjectPy::getCustomAttributes(const char* attr) const
{
- return 0;
+ // search for dynamic property
+ Property* prop = getDocumentObjectPtr()->getDynamicPropertyByName(attr);
+ if (prop)
+ return prop->getPyObject();
+ else
+ return 0;
}
int DocumentObjectPy::setCustomAttributes(const char* attr, PyObject *obj)
{
+ // explicitly search for dynamic property
+ try {
+ Property* prop = getDocumentObjectPtr()->getDynamicPropertyByName(attr);
+ if (prop) {
+ prop->setPyObject(obj);
+ return 1;
+ }
+ }
+ catch (Base::ValueError &exc) {
+ std::stringstream s;
+ s << "Property '" << attr << "': " << exc.what();
+ throw Py::ValueError(s.str());
+ }
+ catch (Base::Exception &exc) {
+ std::stringstream s;
+ s << "Attribute (Name: " << attr << ") error: '" << exc.what() << "' ";
+ throw Py::AttributeError(s.str());
+ }
+ catch (...) {
+ std::stringstream s;
+ s << "Unknown error in attribute " << attr;
+ throw Py::AttributeError(s.str());
+ }
+
// search in PropertyList
Property *prop = getDocumentObjectPtr()->getPropertyByName(attr);
if (prop) {
diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp
index bcd06b459e..77094557ad 100644
--- a/src/App/FeaturePython.cpp
+++ b/src/App/FeaturePython.cpp
@@ -31,8 +31,9 @@
#include
#include
+#include
#include "FeaturePython.h"
-#include "FeaturePythonPyImp.h"
+#include "FeaturePythonPyImp.h"
using namespace App;
@@ -192,7 +193,7 @@ PyObject *FeaturePythonImp::getPyObject(void)
// ---------------------------------------------------------
namespace App {
-PROPERTY_SOURCE_TEMPLATE(App::FeaturePython, App::DocumentObject)
+PROPERTY_SOURCE_TEMPLATE(App::FeaturePython, App::DocumentObject)
template<> const char* App::FeaturePython::getViewProviderName(void) const {
return "Gui::ViewProviderPythonFeature";
}
@@ -208,11 +209,11 @@ template class AppExport FeaturePythonT;
}
// ---------------------------------------------------------
-
+
namespace App {
-PROPERTY_SOURCE_TEMPLATE(App::GeometryPython, App::GeoFeature)
+PROPERTY_SOURCE_TEMPLATE(App::GeometryPython, App::GeoFeature)
template<> const char* App::GeometryPython::getViewProviderName(void) const {
return "Gui::ViewProviderPythonGeometry";
}
// explicit template instantiation
-template class AppExport FeaturePythonT;
}
+template class AppExport FeaturePythonT;}
diff --git a/src/App/FeaturePythonPyImp.h b/src/App/FeaturePythonPyImp.h
index 3ee30c4717..e56d4fa3fe 100644
--- a/src/App/FeaturePythonPyImp.h
+++ b/src/App/FeaturePythonPyImp.h
@@ -26,7 +26,7 @@
#include