PartDesign: add 'VisibleFeature' attribute to BodyPy

This commit is contained in:
Zheng, Lei
2019-08-19 13:39:58 +08:00
committed by wmayer
parent 42b4e4c0a9
commit 5b8d2183fb
2 changed files with 16 additions and 0 deletions

View File

@@ -28,5 +28,11 @@
</UserDocu>
</Documentation>
</Methode>
<Attribute Name="VisibleFeature" ReadOnly="true">
<Documentation>
<UserDocu>Return the the visible feature of this body</UserDocu>
</Documentation>
<Parameter Name="VisibleFeature" Type="Object" />
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -30,6 +30,7 @@
#include "Mod/Part/App/Part2DObject.h"
#include "Mod/PartDesign/App/Body.h"
#include "Mod/PartDesign/App/Feature.h"
// inclusion of the generated files (generated out of ItemPy.xml)
#include "BodyPy.h"
@@ -89,3 +90,12 @@ PyObject* BodyPy::insertObject(PyObject *args)
Py_Return;
}
Py::Object BodyPy::getVisibleFeature() const {
for(auto obj : getBodyPtr()->Group.getValues()) {
if(obj->Visibility.getValue() && obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
return Py::Object(obj->getPyObject(),true);
}
return Py::Object();
}