diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 7d1c3f5a7..d61189d2c 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1716,22 +1716,31 @@ Py::List TopoShapePy::getCompounds(void) const Py::Float TopoShapePy::getLength(void) const { + const TopoDS_Shape& shape = getTopoShapePtr()->_Shape; + if (shape.IsNull()) + throw Py::RuntimeError("shape is invalid"); GProp_GProps props; - BRepGProp::LinearProperties(getTopoShapePtr()->_Shape, props); + BRepGProp::LinearProperties(shape, props); return Py::Float(props.Mass()); } Py::Float TopoShapePy::getArea(void) const { + const TopoDS_Shape& shape = getTopoShapePtr()->_Shape; + if (shape.IsNull()) + throw Py::RuntimeError("shape is invalid"); GProp_GProps props; - BRepGProp::SurfaceProperties(getTopoShapePtr()->_Shape, props); + BRepGProp::SurfaceProperties(shape, props); return Py::Float(props.Mass()); } Py::Float TopoShapePy::getVolume(void) const { + const TopoDS_Shape& shape = getTopoShapePtr()->_Shape; + if (shape.IsNull()) + throw Py::RuntimeError("shape is invalid"); GProp_GProps props; - BRepGProp::VolumeProperties(getTopoShapePtr()->_Shape, props); + BRepGProp::VolumeProperties(shape, props); return Py::Float(props.Mass()); }