diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp index ad7791ede..b69049e6e 100644 --- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp @@ -123,7 +123,7 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pcObj)) { TopoShape* shape = static_cast(pcObj)->getTopoShapePtr(); - if (shape && shape->_Shape.ShapeType() == TopAbs_EDGE) { + if (shape && !shape->_Shape.IsNull() && shape->_Shape.ShapeType() == TopAbs_EDGE) { this->getTopoShapePtr()->_Shape = shape->_Shape; return 0; } @@ -507,6 +507,8 @@ Py::Object TopoShapeEdgePy::getCenterOfMass(void) const Py::Boolean TopoShapeEdgePy::getClosed(void) const { + if (getTopoShapePtr()->_Shape.IsNull()) + throw Py::Exception("Cannot determine the 'Closed'' flag of an empty shape"); Standard_Boolean ok = BRep_Tool::IsClosed(getTopoShapePtr()->_Shape); return Py::Boolean(ok ? true : false); } diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 37b7c18b8..598e7ad8b 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1030,6 +1030,8 @@ PyObject* TopoShapePy::isClosed(PyObject *args) if (!PyArg_ParseTuple(args, "")) return NULL; try { + if (getTopoShapePtr()->_Shape.IsNull()) + Standard_Failure::Raise("Cannot determine the 'Closed'' flag of an empty shape"); return Py_BuildValue("O", (getTopoShapePtr()->isClosed() ? Py_True : Py_False)); } catch (...) {