diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.h b/src/Mod/Sketcher/App/PropertyConstraintList.h index 931a99d0e..97a4f9b62 100644 --- a/src/Mod/Sketcher/App/PropertyConstraintList.h +++ b/src/Mod/Sketcher/App/PropertyConstraintList.h @@ -101,6 +101,9 @@ public: bool scanGeometry(const std::vector &GeoList) const; bool isGeometryInvalid(){return invalidGeometry;} + /// Return status of geometry for better error reporting + bool hasInvalidGeometry() const { return invalidGeometry; } + const Constraint *getConstraint(const App::ObjectIdentifier &path) const; virtual void setPathValue(const App::ObjectIdentifier & path, const boost::any & value); diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 1d2373e99..a96d83e2e 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -268,6 +268,8 @@ int SketchObject::solve(bool updateGeoAfterSolving/*=true*/) int SketchObject::setDatum(int ConstrId, double Datum) { // set the changed value for the constraint + if (this->Constraints.hasInvalidGeometry()) + return -6; const std::vector &vals = this->Constraints.getValues(); if (ConstrId < 0 || ConstrId >= int(vals.size())) return -1; diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 55009ac0f..06cef9eae 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -540,6 +540,8 @@ PyObject* SketchObjectPy::setDatum(PyObject *args) str << "Negative datum values are not valid for the constraint with index " << Index; else if (err == -5) str << "Zero is not a valid datum for the constraint with index " << Index; + else if (err == -6) + str << "Cannot set the datum because of invalid geometry"; else str << "Unexpected problem at setting datum " << (const char*)Quantity.getUserString().toUtf8() << " for the constraint with index " << Index; PyErr_SetString(PyExc_ValueError, str.str().c_str());