0001264: add function Sketch.setConstruction()
This commit is contained in:
parent
789e810213
commit
ee77154e6a
|
@ -375,6 +375,23 @@ int SketchObject::toggleConstruction(int GeoId)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SketchObject::setConstruction(int GeoId, bool on)
|
||||
{
|
||||
const std::vector< Part::Geometry * > &vals = getInternalGeometry();
|
||||
if (GeoId < 0 || GeoId >= int(vals.size()))
|
||||
return -1;
|
||||
|
||||
std::vector< Part::Geometry * > newVals(vals);
|
||||
|
||||
Part::Geometry *geoNew = newVals[GeoId]->clone();
|
||||
geoNew->Construction = on;
|
||||
newVals[GeoId]=geoNew;
|
||||
|
||||
this->Geometry.setValues(newVals);
|
||||
this->Constraints.acceptGeometry(getCompleteGeometry());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SketchObject::addConstraints(const std::vector<Constraint *> &ConstraintList)
|
||||
{
|
||||
return -1;
|
||||
|
|
|
@ -115,6 +115,7 @@ public:
|
|||
|
||||
/// toggle geometry to draft line
|
||||
int toggleConstruction(int GeoId);
|
||||
int setConstruction(int GeoId, bool on);
|
||||
|
||||
/// create a fillet
|
||||
int fillet(int geoId, PointPos pos, double radius, bool trim=true);
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
<UserDocu>switch a geometry to a construcion line</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setConstruction">
|
||||
<Documentation>
|
||||
<UserDocu>set construction mode of a geometry on or off</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="addConstraint">
|
||||
<Documentation>
|
||||
<UserDocu>add a constraint to the sketch</UserDocu>
|
||||
|
|
|
@ -99,6 +99,23 @@ PyObject* SketchObjectPy::toggleConstruction(PyObject *args)
|
|||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::setConstruction(PyObject *args)
|
||||
{
|
||||
int Index;
|
||||
PyObject *Mode;
|
||||
if (!PyArg_ParseTuple(args, "iO!", &Index, &PyBool_Type, &Mode))
|
||||
return 0;
|
||||
|
||||
if (this->getSketchObjectPtr()->setConstruction(Index, PyObject_IsTrue(Mode) ? true : false)) {
|
||||
std::stringstream str;
|
||||
str << "Not able to set construction mode of a geometry with the given index: " << Index;
|
||||
PyErr_SetString(PyExc_ValueError, str.str().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* SketchObjectPy::addConstraint(PyObject *args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
|
|
Loading…
Reference in New Issue
Block a user