Sketch: expose several methods to Python
* expose detectDegeneratedGeometries to Python * expose removeDegeneratedGeometries to Python * expose delConstraintsToExternal to Python * expose evaluateConstraints to Python * expose validateConstraints to Python
This commit is contained in:
@@ -94,6 +94,38 @@ deleteAllGeometry()
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="detectDegeneratedGeometries">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Detect degenerated geometries. A curve geometry is considered degenerated
|
||||
if the parameter range is less than the tolerance.
|
||||
|
||||
detectDegeneratedGeometries(tolerance:float)
|
||||
|
||||
Args:
|
||||
tolerance: The tolerance to check the parameter range of a curve.
|
||||
|
||||
Returns:
|
||||
The number of degenerated geometries.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeDegeneratedGeometries">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Remove degenerated geometries. A curve geometry is considered degenerated
|
||||
if the parameter range is less than the tolerance.
|
||||
|
||||
removeDegeneratedGeometries(tolerance:float)
|
||||
|
||||
Args:
|
||||
tolerance: The tolerance to check the parameter range of a curve.
|
||||
|
||||
Returns:
|
||||
The number of degenerated geometries.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="deleteAllConstraints">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
@@ -263,6 +295,11 @@ delConstraintOnPoint(geoId:int, pointPos:int)
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="delConstraintsToExternal" NoArgs="true">
|
||||
<Documentation>
|
||||
<UserDocu>Deletes all constraints referencing an external geometry.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setDatum">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
@@ -720,6 +757,20 @@ setLabelDistance(constraintIndex:int, value:float)
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="evaluateConstraints" Const="true" NoArgs="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Check for constraints with invalid indexes. Returns True if invalid constraints are found, False otherwise.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="validateConstraints" NoArgs="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Removes constraints with invalid indexes.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="autoRemoveRedundants">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
// other python types
|
||||
#include "ConstraintPy.h"
|
||||
#include "GeometryFacadePy.h"
|
||||
#include "SketchAnalysis.h"
|
||||
|
||||
|
||||
using namespace Sketcher;
|
||||
@@ -260,6 +261,30 @@ PyObject* SketchObjectPy::deleteAllGeometry(PyObject* args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::detectDegeneratedGeometries(PyObject* args)
|
||||
{
|
||||
double tolerance {};
|
||||
if (!PyArg_ParseTuple(args, "d", &tolerance)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SketchAnalysis analyse(this->getSketchObjectPtr());
|
||||
int count = analyse.detectDegeneratedGeometries(tolerance);
|
||||
return Py::new_reference_to(Py::Long(count));
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::removeDegeneratedGeometries(PyObject* args)
|
||||
{
|
||||
double tolerance {};
|
||||
if (!PyArg_ParseTuple(args, "d", &tolerance)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SketchAnalysis analyse(this->getSketchObjectPtr());
|
||||
int count = analyse.removeDegeneratedGeometries(tolerance);
|
||||
return Py::new_reference_to(Py::Long(count));
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::deleteAllConstraints(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
@@ -617,6 +642,12 @@ PyObject* SketchObjectPy::delConstraintOnPoint(PyObject* args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::delConstraintsToExternal()
|
||||
{
|
||||
this->getSketchObjectPtr()->delConstraintsToExternal();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::setDatum(PyObject* args)
|
||||
{
|
||||
double Datum;
|
||||
@@ -1941,6 +1972,18 @@ PyObject* SketchObjectPy::makeMissingEquality(PyObject* args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::evaluateConstraints()
|
||||
{
|
||||
bool ok = this->getSketchObjectPtr()->evaluateConstraints();
|
||||
return Py::new_reference_to(Py::Boolean(ok));
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::validateConstraints()
|
||||
{
|
||||
this->getSketchObjectPtr()->validateConstraints();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::autoRemoveRedundants(PyObject* args)
|
||||
{
|
||||
PyObject* updategeo = Py_True;
|
||||
|
||||
Reference in New Issue
Block a user