Improved SketchObject error reporting

This commit is contained in:
jrheinlaender 2013-09-12 16:18:08 +02:00 committed by Stefan Tröger
parent 0ab6a77442
commit 37a8c02bc6
3 changed files with 7 additions and 0 deletions

View File

@ -101,6 +101,9 @@ public:
bool scanGeometry(const std::vector<Part::Geometry *> &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);

View File

@ -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<Constraint *> &vals = this->Constraints.getValues();
if (ConstrId < 0 || ConstrId >= int(vals.size()))
return -1;

View File

@ -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());