diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index d7b299d9b..ec4cfa8c2 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -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 &ConstraintList) { return -1; diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 0cd4af863..d77cd17d5 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -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); diff --git a/src/Mod/Sketcher/App/SketchObjectPy.xml b/src/Mod/Sketcher/App/SketchObjectPy.xml index e5b93b44e..41f035754 100644 --- a/src/Mod/Sketcher/App/SketchObjectPy.xml +++ b/src/Mod/Sketcher/App/SketchObjectPy.xml @@ -33,6 +33,11 @@ switch a geometry to a construcion line + + + set construction mode of a geometry on or off + + add a constraint to the sketch diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 1d0b5129f..474369479 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -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;