Sketcher: Python command to delete all internal geometry and constraints of an sketch

This commit is contained in:
Abdullah Tahiri
2017-11-05 07:29:19 +01:00
committed by wmayer
parent 7f5e0caf3e
commit 3aec9b3859
4 changed files with 41 additions and 0 deletions

View File

@@ -722,6 +722,23 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo)
return 0;
}
int SketchObject::deleteAllGeometry()
{
std::vector< Part::Geometry * > newVals(0);
std::vector< Constraint * > newConstraints(0);
this->Geometry.setValues(newVals);
this->Constraints.setValues(newConstraints);
this->Constraints.acceptGeometry(getCompleteGeometry());
rebuildVertexIndex();
if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
solve();
return 0;
}
int SketchObject::toggleConstruction(int GeoId)
{
const std::vector< Part::Geometry * > &vals = getInternalGeometry();

View File

@@ -97,6 +97,8 @@ public:
\retval int - 0 if successful
*/
int delGeometry(int GeoId, bool deleteinternalgeo = true);
/// deletes all the elements/constraints of the sketch except for external geometry
int deleteAllGeometry();
/// add all constraints in the list
int addConstraints(const std::vector<Constraint *> &ConstraintList);
/// add constraint

View File

@@ -28,6 +28,11 @@
<UserDocu>delete a geometric object from the sketch</UserDocu>
</Documentation>
</Methode>
<Methode Name="deleteAllGeometry">
<Documentation>
<UserDocu>delete all the geometry objects and constraints from the sketch except external geometry</UserDocu>
</Documentation>
</Methode>
<Methode Name="toggleConstruction">
<Documentation>
<UserDocu>switch a geometry to a construction line</UserDocu>

View File

@@ -213,6 +213,23 @@ PyObject* SketchObjectPy::delGeometry(PyObject *args)
Py_Return;
}
PyObject* SketchObjectPy::deleteAllGeometry(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
if (this->getSketchObjectPtr()->deleteAllGeometry()) {
std::stringstream str;
str << "Unable to delete Geometry";
PyErr_SetString(PyExc_ValueError, str.str().c_str());
return 0;
}
Py_Return;
}
PyObject* SketchObjectPy::toggleConstruction(PyObject *args)
{
int Index;