PartDesign: Adopt python interface to body group
This commit is contained in:
@@ -62,7 +62,7 @@ Body::Body() {
|
||||
// Note: The following code will catch Python Document::removeObject() modifications. If the object removed is
|
||||
// a member of the Body::Group, then it will be automatically removed from the Group property which triggers the
|
||||
// following two methods
|
||||
// But since we require the Python user to call both Document::addObject() and Body::addFeature(), we should
|
||||
// But since we require the Python user to call both Document::addObject() and Body::addObject(), we should
|
||||
// also require calling both Document::removeObject and Body::removeFeature() in order to be consistent
|
||||
void Body::onBeforeChange(const App::Property *prop)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
* and into the begin if where is InsertAfter.
|
||||
* @param after if true insert the feature after the target. Default is false.
|
||||
*
|
||||
* @note the methode doesn't modifies the Tip unlike addFeature()
|
||||
* @note the methode doesn't modifies the Tip unlike addObject()
|
||||
*/
|
||||
void insertObject(App::DocumentObject* feature, App::DocumentObject* target, bool after=false);
|
||||
|
||||
|
||||
@@ -13,14 +13,9 @@
|
||||
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
|
||||
<UserDocu>PartDesign body class</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="addFeature">
|
||||
<Methode Name="insertObject">
|
||||
<Documentation>
|
||||
<UserDocu>addFeature(feat) - Add the given feature after the current Tip feature</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="insertFeature">
|
||||
<Documentation>
|
||||
<UserDocu>insertFeatureAfter(feature, target, after=False)
|
||||
<UserDocu>insertObject(feature, target, after=False)
|
||||
Insert the feature into the body after the given feature.
|
||||
|
||||
@param feature The feature to insert into the body
|
||||
@@ -29,19 +24,9 @@
|
||||
and into the begin if where is InsertAfter.
|
||||
@param after if true insert the feature after the target. Default is false.
|
||||
|
||||
@note the methode doesn't modifies the Tip unlike addFeature()
|
||||
@note the methode doesn't modifies the Tip unlike addObject()
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeFeature">
|
||||
<Documentation>
|
||||
<UserDocu>removeFeature(feat) - Remove the given feature from the Body</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeModelFromDocument">
|
||||
<Documentation>
|
||||
<UserDocu>Delets all the objects linked to the model.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -52,32 +52,7 @@ int BodyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::addFeature(PyObject *args)
|
||||
{
|
||||
PyObject* featurePy;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &featurePy))
|
||||
return 0;
|
||||
|
||||
App::DocumentObject* feature = static_cast<App::DocumentObjectPy*>(featurePy)->getDocumentObjectPtr();
|
||||
|
||||
if (!Body::isAllowed(feature)) {
|
||||
PyErr_SetString(PyExc_SystemError, "Only PartDesign features, datum features and sketches can be inserted into a Body");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Body* body = this->getBodyPtr();
|
||||
|
||||
try {
|
||||
body->addObject(feature);
|
||||
} catch (Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_SystemError, e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::insertFeature(PyObject *args)
|
||||
PyObject* BodyPy::insertObject(PyObject *args)
|
||||
{
|
||||
PyObject* featurePy;
|
||||
PyObject* targetPy;
|
||||
@@ -115,32 +90,3 @@ PyObject* BodyPy::insertFeature(PyObject *args)
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::removeFeature(PyObject *args)
|
||||
{
|
||||
PyObject* featurePy;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &featurePy))
|
||||
return 0;
|
||||
|
||||
App::DocumentObject* feature = static_cast<App::DocumentObjectPy*>(featurePy)->getDocumentObjectPtr();
|
||||
Body* body = this->getBodyPtr();
|
||||
|
||||
try {
|
||||
body->removeObject(feature);
|
||||
} catch (Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_SystemError, e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::removeModelFromDocument(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
|
||||
getBodyPtr()->removeObjectsFromDocument();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user