Work on inserting, removing, hiding and showing features in the body
This commit is contained in:
committed by
Stefan Tröger
parent
218f386990
commit
8390bbb999
@@ -1,7 +1,9 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "Mod/Part/App/Part2DObject.h"
|
||||
#include "Mod/PartDesign/App/Body.h"
|
||||
#include "Mod/PartDesign/App/DatumFeature.h"
|
||||
|
||||
// inclusion of the generated files (generated out of ItemPy.xml)
|
||||
#include "BodyPy.h"
|
||||
@@ -27,4 +29,48 @@ int BodyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::insertFeature(PyObject *args)
|
||||
{
|
||||
PyObject* featurePy;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Part::PartFeaturePy::Type), &featurePy))
|
||||
return 0;
|
||||
|
||||
Part::Feature* feature = static_cast<Part::PartFeaturePy*>(featurePy)->getFeaturePtr();
|
||||
|
||||
if (!feature->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) &&
|
||||
!feature->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
PyErr_SetString(PyExc_SystemError, "Only PartDesign features and sketches can be inserted into a Body");
|
||||
return 0;
|
||||
}
|
||||
Body* body = this->getBodyPtr();
|
||||
|
||||
try {
|
||||
body->insertFeature(feature);
|
||||
} catch (Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_SystemError, e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::removeFeature(PyObject *args)
|
||||
{
|
||||
PyObject* featurePy;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Part::PartFeaturePy::Type), &featurePy))
|
||||
return 0;
|
||||
|
||||
Part::Feature* feature = static_cast<Part::PartFeaturePy*>(featurePy)->getFeaturePtr();
|
||||
Body* body = this->getBodyPtr();
|
||||
|
||||
try {
|
||||
body->removeFeature(feature);
|
||||
} catch (Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_SystemError, e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user