diff --git a/src/Mod/Part/App/GeometryPy.xml b/src/Mod/Part/App/GeometryPy.xml
index d309f9f3af..b557acacd3 100644
--- a/src/Mod/Part/App/GeometryPy.xml
+++ b/src/Mod/Part/App/GeometryPy.xml
@@ -43,6 +43,11 @@ It describes the common behavior of these objects when:
Translates this geometric object
+
+
+ Create a copy of this geometry
+
+
Defines this geometry as a construction one which
diff --git a/src/Mod/Part/App/GeometryPyImp.cpp b/src/Mod/Part/App/GeometryPyImp.cpp
index fb8055842a..7e761c80e3 100644
--- a/src/Mod/Part/App/GeometryPyImp.cpp
+++ b/src/Mod/Part/App/GeometryPyImp.cpp
@@ -183,6 +183,33 @@ PyObject* GeometryPy::translate(PyObject *args)
return 0;
}
+PyObject* GeometryPy::copy(PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ Part::Geometry* geom = this->getGeometryPtr();
+ PyTypeObject* type = this->GetType();
+ PyObject* cpy = 0;
+ // let the type object decide
+ if (type->tp_new)
+ cpy = type->tp_new(type, this, 0);
+ if (!cpy) {
+ PyErr_SetString(PyExc_TypeError, "failed to create copy of geometry");
+ return 0;
+ }
+
+ Part::GeometryPy* geompy = static_cast(cpy);
+ // the PyMake function must have created the corresponding instance of the 'Geometry' subclass
+ // so delete it now to avoid a memory leak
+ if (geompy->_pcTwinPointer) {
+ Part::Geometry* clone = static_cast(geompy->_pcTwinPointer);
+ delete clone;
+ }
+ geompy->_pcTwinPointer = geom->clone();
+ return cpy;
+}
+
Py::Boolean GeometryPy::getConstruction(void) const
{
return Py::Boolean(getGeometryPtr()->Construction);