diff --git a/src/Mod/Fem/App/AppFem.cpp b/src/Mod/Fem/App/AppFem.cpp index 11a9dd4128b6..66c3a0275b3a 100644 --- a/src/Mod/Fem/App/AppFem.cpp +++ b/src/Mod/Fem/App/AppFem.cpp @@ -118,6 +118,7 @@ void AppFemExport initFem() Fem::FemAnalysis ::init(); Fem::FemAnalysisPython ::init(); + Fem::FeaturePython ::init(); Fem::FemMesh ::init(); Fem::FemMeshObject ::init(); Fem::FemMeshShapeObject ::init(); diff --git a/src/Mod/Fem/App/FemAnalysis.cpp b/src/Mod/Fem/App/FemAnalysis.cpp index 1abb701b8e02..1aaa113d2882 100644 --- a/src/Mod/Fem/App/FemAnalysis.cpp +++ b/src/Mod/Fem/App/FemAnalysis.cpp @@ -28,6 +28,7 @@ #include "FemAnalysis.h" #include +#include #include #include @@ -88,4 +89,24 @@ template<> const char* Fem::FemAnalysisPython::getViewProviderName(void) const { // explicit template instantiation template class AppFemExport FeaturePythonT; -} \ No newline at end of file +} + +// --------------------------------------------------------- + +namespace App { +/// @cond DOXERR +PROPERTY_SOURCE_TEMPLATE(Fem::FeaturePython, App::DocumentObject) +template<> const char* Fem::FeaturePython::getViewProviderName(void) const { + return "Gui::ViewProviderPythonFeature"; +} +template<> PyObject* Fem::FeaturePython::getPyObject(void) { + if (PythonObject.is(Py::_None())) { + // ref counter is set to 1 + PythonObject = Py::Object(new App::FeaturePythonPyT(this),true); + } + return Py::new_reference_to(PythonObject); +} +// explicit template instantiation +template class AppFemExport FeaturePythonT; +/// @endcond +} diff --git a/src/Mod/Fem/App/FemAnalysis.h b/src/Mod/Fem/App/FemAnalysis.h index 9c16f49a8f81..ea61513de8de 100644 --- a/src/Mod/Fem/App/FemAnalysis.h +++ b/src/Mod/Fem/App/FemAnalysis.h @@ -65,6 +65,7 @@ class AppFemExport FemAnalysis : public App::DocumentObject }; typedef App::FeaturePythonT FemAnalysisPython; +typedef App::FeaturePythonT FeaturePython; } //namespace Fem diff --git a/src/Mod/Fem/FemBeamSection.py b/src/Mod/Fem/FemBeamSection.py index 3df09784ccf6..f30fac58b843 100644 --- a/src/Mod/Fem/FemBeamSection.py +++ b/src/Mod/Fem/FemBeamSection.py @@ -37,7 +37,7 @@ def makeFemBeamSection(width=20.0, height=20.0, name="BeamSection"): '''makeFemBeamSection([width], [height], [name]): creates an beamsection object to define a cross section''' - obj = FemGui.getActiveAnalysis().Document.addObject("App::FeaturePython", name) + obj = FemGui.getActiveAnalysis().Document.addObject("Fem::FeaturePython", name) _FemBeamSection(obj) obj.Width = width obj.Height = height diff --git a/src/Mod/Fem/FemShellThickness.py b/src/Mod/Fem/FemShellThickness.py index 11a9b7081b8a..9b6c04e942e3 100644 --- a/src/Mod/Fem/FemShellThickness.py +++ b/src/Mod/Fem/FemShellThickness.py @@ -37,7 +37,7 @@ def makeFemShellThickness(thickness=20.0, name="ShellThickness"): '''makeFemShellThickness([thickness], [name]): creates an shellthickness object to define a plate thickness''' - obj = FemGui.getActiveAnalysis().Document.addObject("App::FeaturePython", name) + obj = FemGui.getActiveAnalysis().Document.addObject("Fem::FeaturePython", name) _FemShellThickness(obj) obj.Thickness = thickness if FreeCAD.GuiUp: diff --git a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp index ade63097ad5e..aa44cee485e0 100644 --- a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp +++ b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp @@ -175,6 +175,8 @@ bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject* obj) const return true; else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId())) return true; + else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython"))) + return true; else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId())) return true; else