add method to sketch object to get index by user-defined name
This commit is contained in:
@@ -63,6 +63,14 @@
|
||||
<UserDocu>Rename a constraint of the sketch</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getIndexByName" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Get the index of the constraint by name.
|
||||
If there is no such constraint an exception is raised.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="carbonCopy">
|
||||
<Documentation>
|
||||
<UserDocu>copy another sketch's geometry and constraints</UserDocu>
|
||||
@@ -88,7 +96,7 @@
|
||||
<UserDocu>set the Datum of a Distance or Angle constraint</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getDatum">
|
||||
<Methode Name="getDatum" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Get the value of a datum constraint</UserDocu>
|
||||
</Documentation>
|
||||
@@ -108,7 +116,7 @@
|
||||
<UserDocu>Moves all datum constraints to the end of the constraint list</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getDriving">
|
||||
<Methode Name="getDriving" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Get the Driving status of a datum constraint</UserDocu>
|
||||
</Documentation>
|
||||
@@ -138,7 +146,7 @@
|
||||
<UserDocu>sets the constraint on/off (enforced or not)</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getActive">
|
||||
<Methode Name="getActive" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Get the constraint status (enforced or not)</UserDocu>
|
||||
</Documentation>
|
||||
@@ -163,14 +171,14 @@
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getPoint">
|
||||
<Methode Name="getPoint" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
getPoint(GeoIndex,PointPos) - retrieve the vector of a point in the sketch
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getAxis">
|
||||
<Methode Name="getAxis" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
return an axis based on the corresponding construction line
|
||||
|
||||
@@ -406,6 +406,31 @@ PyObject* SketchObjectPy::renameConstraint(PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::getIndexByName(PyObject *args)
|
||||
{
|
||||
char* utf8Name;
|
||||
if (!PyArg_ParseTuple(args, "et", "utf-8", &utf8Name))
|
||||
return 0;
|
||||
|
||||
std::string Name = utf8Name;
|
||||
PyMem_Free(utf8Name);
|
||||
|
||||
if (Name.empty()) {
|
||||
PyErr_SetString(PyExc_ValueError, "Passed string is empty");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::vector< Sketcher::Constraint * > &vals = getSketchObjectPtr()->Constraints.getValues();
|
||||
for (std::size_t i = 0; i < vals.size(); ++i) {
|
||||
if (Name == vals[i]->Name) {
|
||||
return Py_BuildValue("i", i);
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_LookupError, "No such constraint found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::carbonCopy(PyObject *args)
|
||||
{
|
||||
char *ObjectName;
|
||||
|
||||
Reference in New Issue
Block a user