From 5b8d2183fb9415f013418146205bf4ecdf909cb3 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Mon, 19 Aug 2019 13:39:58 +0800 Subject: [PATCH] PartDesign: add 'VisibleFeature' attribute to BodyPy --- src/Mod/PartDesign/App/BodyPy.xml | 6 ++++++ src/Mod/PartDesign/App/BodyPyImp.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Mod/PartDesign/App/BodyPy.xml b/src/Mod/PartDesign/App/BodyPy.xml index aa3e05abe3..8aadafec57 100644 --- a/src/Mod/PartDesign/App/BodyPy.xml +++ b/src/Mod/PartDesign/App/BodyPy.xml @@ -28,5 +28,11 @@ + + + Return the the visible feature of this body + + + diff --git a/src/Mod/PartDesign/App/BodyPyImp.cpp b/src/Mod/PartDesign/App/BodyPyImp.cpp index 83169f54ab..89f6a08320 100644 --- a/src/Mod/PartDesign/App/BodyPyImp.cpp +++ b/src/Mod/PartDesign/App/BodyPyImp.cpp @@ -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(); +} +