diff --git a/src/Base/TypePy.xml b/src/Base/TypePy.xml
index c05be1940f..ccccd1253b 100644
--- a/src/Base/TypePy.xml
+++ b/src/Base/TypePy.xml
@@ -64,6 +64,16 @@ namespace Base {
Returns all descendants
+
+
+ Creates an instance of this type
+
+
+
+
+ Creates an instance of the named type
+
+
The name of the type id
diff --git a/src/Base/TypePyImp.cpp b/src/Base/TypePyImp.cpp
index 69806d32ae..9cec3ce344 100644
--- a/src/Base/TypePyImp.cpp
+++ b/src/Base/TypePyImp.cpp
@@ -167,6 +167,37 @@ PyObject* TypePy::getAllDerived(PyObject *args)
return Py::new_reference_to(res);
}
+PyObject* TypePy::createInstance (PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return nullptr;
+
+ Base::BaseClass* base = static_cast(getBaseTypePtr()->createInstance());
+ if (!base) {
+ Py_Return;
+ }
+
+ //TODO: At the moment "base" will never be destroyed and causes a memory leak
+ return base->getPyObject();
+}
+
+PyObject* TypePy::createInstanceByName (PyObject *args)
+{
+ const char* type;
+ PyObject* load = Py_False;
+ if (!PyArg_ParseTuple(args, "s|O!", &type, &PyBool_Type, &load))
+ return nullptr;
+
+ Base::BaseClass* base = static_cast
+ (Base::Type::createInstanceByName(type, PyObject_IsTrue(load) ? true : false));
+ if (!base) {
+ Py_Return;
+ }
+
+ //TODO: At the moment "base" will never be destroyed and causes a memory leak
+ return base->getPyObject();
+}
+
Py::String TypePy::getName(void) const
{
return Py::String(std::string(getBaseTypePtr()->getName()));