Skip to content

Commit

Permalink
+ fixes #1690: sketch.getPoint crashes FreeCAD if the point does not …
Browse files Browse the repository at this point in the history
…exist
  • Loading branch information
wwmayer committed Aug 16, 2014
1 parent 92cb03b commit 8808b82
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Mod/Sketcher/App/SketchObjectPyImp.cpp
Expand Up @@ -357,7 +357,18 @@ PyObject* SketchObjectPy::getPoint(PyObject *args)
if (!PyArg_ParseTuple(args, "ii", &GeoId, &PointType))
return 0;

return new Base::VectorPy(new Base::Vector3d(this->getSketchObjectPtr()->getPoint(GeoId,(Sketcher::PointPos)PointType)));
if (PointType < 0 || PointType > 3) {
PyErr_SetString(PyExc_ValueError, "Invalid point type");
return 0;
}

SketchObject* obj = this->getSketchObjectPtr();
if (GeoId > obj->getHighestCurveIndex() || -GeoId > obj->getExternalGeometryCount()) {
PyErr_SetString(PyExc_ValueError, "Invalid geometry Id");
return 0;
}

return new Base::VectorPy(new Base::Vector3d(obj->getPoint(GeoId,(Sketcher::PointPos)PointType)));
}

PyObject* SketchObjectPy::getAxis(PyObject *args)
Expand Down

0 comments on commit 8808b82

Please sign in to comment.