expose FeatureAddSub to Python, fixes #0000955
This commit is contained in:
@@ -84,65 +84,68 @@ PyMOD_INIT_FUNC(_PartDesign)
|
||||
// call PyType_Ready, otherwise we run into a segmentation fault, later on.
|
||||
// This function is responsible for adding inherited slots from a type's base class.
|
||||
|
||||
PartDesign::Feature ::init();
|
||||
PartDesign::FeaturePython ::init();
|
||||
PartDesign::Solid ::init();
|
||||
PartDesign::DressUp ::init();
|
||||
PartDesign::FeatureAddSub ::init();
|
||||
PartDesign::ProfileBased ::init();
|
||||
PartDesign::Transformed ::init();
|
||||
PartDesign::Mirrored ::init();
|
||||
PartDesign::LinearPattern ::init();
|
||||
PartDesign::PolarPattern ::init();
|
||||
PartDesign::Scaled ::init();
|
||||
PartDesign::MultiTransform ::init();
|
||||
PartDesign::Hole ::init();
|
||||
PartDesign::Body ::init();
|
||||
PartDesign::Pad ::init();
|
||||
PartDesign::Pocket ::init();
|
||||
PartDesign::Fillet ::init();
|
||||
PartDesign::Revolution ::init();
|
||||
PartDesign::Groove ::init();
|
||||
PartDesign::Chamfer ::init();
|
||||
PartDesign::Draft ::init();
|
||||
PartDesign::Thickness ::init();
|
||||
PartDesign::Pipe ::init();
|
||||
PartDesign::AdditivePipe ::init();
|
||||
PartDesign::SubtractivePipe ::init();
|
||||
PartDesign::Loft ::init();
|
||||
PartDesign::AdditiveLoft ::init();
|
||||
PartDesign::SubtractiveLoft ::init();
|
||||
PartDesign::ShapeBinder ::init();
|
||||
PartDesign::Plane ::init();
|
||||
PartDesign::Line ::init();
|
||||
PartDesign::Point ::init();
|
||||
PartDesign::CoordinateSystem ::init();
|
||||
PartDesign::Boolean ::init();
|
||||
PartDesign::FeaturePrimitive ::init();
|
||||
PartDesign::Box ::init();
|
||||
PartDesign::AdditiveBox ::init();
|
||||
PartDesign::SubtractiveBox ::init();
|
||||
PartDesign::Cylinder ::init();
|
||||
PartDesign::AdditiveCylinder ::init();
|
||||
PartDesign::SubtractiveCylinder::init();
|
||||
PartDesign::Sphere ::init();
|
||||
PartDesign::AdditiveSphere ::init();
|
||||
PartDesign::SubtractiveSphere ::init();
|
||||
PartDesign::Cone ::init();
|
||||
PartDesign::AdditiveCone ::init();
|
||||
PartDesign::SubtractiveCone ::init();
|
||||
PartDesign::Ellipsoid ::init();
|
||||
PartDesign::AdditiveEllipsoid ::init();
|
||||
PartDesign::SubtractiveEllipsoid ::init();
|
||||
PartDesign::Torus ::init();
|
||||
PartDesign::AdditiveTorus ::init();
|
||||
PartDesign::SubtractiveTorus ::init();
|
||||
PartDesign::Prism ::init();
|
||||
PartDesign::AdditivePrism ::init();
|
||||
PartDesign::SubtractivePrism ::init();
|
||||
PartDesign::Wedge ::init();
|
||||
PartDesign::AdditiveWedge ::init();
|
||||
PartDesign::SubtractiveWedge ::init();
|
||||
PartDesign::Feature ::init();
|
||||
PartDesign::FeaturePython ::init();
|
||||
PartDesign::Solid ::init();
|
||||
PartDesign::DressUp ::init();
|
||||
PartDesign::FeatureAddSub ::init();
|
||||
PartDesign::FeatureAddSubPython ::init();
|
||||
PartDesign::FeatureAdditivePython ::init();
|
||||
PartDesign::FeatureSubtractivePython ::init();
|
||||
PartDesign::ProfileBased ::init();
|
||||
PartDesign::Transformed ::init();
|
||||
PartDesign::Mirrored ::init();
|
||||
PartDesign::LinearPattern ::init();
|
||||
PartDesign::PolarPattern ::init();
|
||||
PartDesign::Scaled ::init();
|
||||
PartDesign::MultiTransform ::init();
|
||||
PartDesign::Hole ::init();
|
||||
PartDesign::Body ::init();
|
||||
PartDesign::Pad ::init();
|
||||
PartDesign::Pocket ::init();
|
||||
PartDesign::Fillet ::init();
|
||||
PartDesign::Revolution ::init();
|
||||
PartDesign::Groove ::init();
|
||||
PartDesign::Chamfer ::init();
|
||||
PartDesign::Draft ::init();
|
||||
PartDesign::Thickness ::init();
|
||||
PartDesign::Pipe ::init();
|
||||
PartDesign::AdditivePipe ::init();
|
||||
PartDesign::SubtractivePipe ::init();
|
||||
PartDesign::Loft ::init();
|
||||
PartDesign::AdditiveLoft ::init();
|
||||
PartDesign::SubtractiveLoft ::init();
|
||||
PartDesign::ShapeBinder ::init();
|
||||
PartDesign::Plane ::init();
|
||||
PartDesign::Line ::init();
|
||||
PartDesign::Point ::init();
|
||||
PartDesign::CoordinateSystem ::init();
|
||||
PartDesign::Boolean ::init();
|
||||
PartDesign::FeaturePrimitive ::init();
|
||||
PartDesign::Box ::init();
|
||||
PartDesign::AdditiveBox ::init();
|
||||
PartDesign::SubtractiveBox ::init();
|
||||
PartDesign::Cylinder ::init();
|
||||
PartDesign::AdditiveCylinder ::init();
|
||||
PartDesign::SubtractiveCylinder ::init();
|
||||
PartDesign::Sphere ::init();
|
||||
PartDesign::AdditiveSphere ::init();
|
||||
PartDesign::SubtractiveSphere ::init();
|
||||
PartDesign::Cone ::init();
|
||||
PartDesign::AdditiveCone ::init();
|
||||
PartDesign::SubtractiveCone ::init();
|
||||
PartDesign::Ellipsoid ::init();
|
||||
PartDesign::AdditiveEllipsoid ::init();
|
||||
PartDesign::SubtractiveEllipsoid ::init();
|
||||
PartDesign::Torus ::init();
|
||||
PartDesign::AdditiveTorus ::init();
|
||||
PartDesign::SubtractiveTorus ::init();
|
||||
PartDesign::Prism ::init();
|
||||
PartDesign::AdditivePrism ::init();
|
||||
PartDesign::SubtractivePrism ::init();
|
||||
PartDesign::Wedge ::init();
|
||||
PartDesign::AdditiveWedge ::init();
|
||||
PartDesign::SubtractiveWedge ::init();
|
||||
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include <App/FeaturePythonPyImp.h>
|
||||
#include "FeatureAddSub.h"
|
||||
#include "FeaturePy.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
@@ -48,3 +50,50 @@ FeatureAddSub::Type FeatureAddSub::getAddSubType()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(PartDesign::FeatureAddSubPython, PartDesign::FeatureAddSub)
|
||||
template<> const char* PartDesign::FeatureAddSubPython::getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderPython";
|
||||
}
|
||||
template<> PyObject* PartDesign::FeatureAddSubPython::getPyObject(void) {
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new FeaturePythonPyT<PartDesign::FeaturePy>(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class PartDesignExport FeaturePythonT<PartDesign::FeatureAddSub>;
|
||||
}
|
||||
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::FeatureAdditivePython, PartDesign::FeatureAddSubPython)
|
||||
|
||||
FeatureAdditivePython::FeatureAdditivePython()
|
||||
{
|
||||
addSubType = Additive;
|
||||
}
|
||||
|
||||
FeatureAdditivePython::~FeatureAdditivePython()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::FeatureSubtractivePython, PartDesign::FeatureAddSubPython)
|
||||
|
||||
FeatureSubtractivePython::FeatureSubtractivePython()
|
||||
{
|
||||
addSubType = Subtractive;
|
||||
}
|
||||
|
||||
FeatureSubtractivePython::~FeatureSubtractivePython()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,6 +53,26 @@ protected:
|
||||
Type addSubType;
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<FeatureAddSub> FeatureAddSubPython;
|
||||
|
||||
class FeatureAdditivePython : public FeatureAddSubPython
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::FeatureAdditivePython);
|
||||
|
||||
public:
|
||||
FeatureAdditivePython();
|
||||
~FeatureAdditivePython();
|
||||
};
|
||||
|
||||
class FeatureSubtractivePython : public FeatureAddSubPython
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::FeatureSubtractivePython);
|
||||
|
||||
public:
|
||||
FeatureSubtractivePython();
|
||||
~FeatureSubtractivePython();
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,10 @@ using namespace PartDesign;
|
||||
// returns a string which represent the object e.g. when printed in python
|
||||
std::string FeaturePy::representation(void) const
|
||||
{
|
||||
return std::string("<PartDesign::Feature>");
|
||||
App::DocumentObject* object = this->getFeaturePtr();
|
||||
std::stringstream str;
|
||||
str << "<" << object->getTypeId().getName() << ">";
|
||||
return str.str();
|
||||
}
|
||||
|
||||
PyObject *FeaturePy::getCustomAttributes(const char* ) const
|
||||
|
||||
Reference in New Issue
Block a user