From 1a96fa60ce053ed6d376abe7fb1edaffb2e79e64 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 30 Nov 2021 20:04:31 +0100 Subject: [PATCH] Part: add exception handling to Face.makeEvolved/Wire.makeEvolved --- src/Mod/Part/App/TopoShapeFacePyImp.cpp | 23 +++++++++++++++-------- src/Mod/Part/App/TopoShapeWirePyImp.cpp | 23 +++++++++++++++-------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp index fba5f73879..089857d117 100644 --- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp @@ -444,10 +444,11 @@ PyObject* TopoShapeFacePy::makeOffset(PyObject *args) } /* +import PartEnums v = App.Vector profile = Part.makePolygon([v(0.,0.,0.), v(-60.,-60.,-100.), v(-60.,-60.,-140.)]) spine = Part.Face(Part.makePolygon([v(0.,0.,0.), v(100.,0.,0.), v(100.,100.,0.), v(0.,100.,0.), v(0.,0.,0.)])) -evolve = spine.makeEvolved(profile) +evolve = spine.makeEvolved(Profile=profile, Join=PartEnums.JoinType.Arc) */ PyObject* TopoShapeFacePy::makeEvolved(PyObject *args, PyObject *kwds) { @@ -487,13 +488,19 @@ PyObject* TopoShapeFacePy::makeEvolved(PyObject *args, PyObject *kwds) break; } - BRepOffsetAPI_MakeEvolved evolved(spine, profile, joinType, - PyObject_IsTrue(AxeProf) ? Standard_True : Standard_False, - PyObject_IsTrue(Solid) ? Standard_True : Standard_False, - PyObject_IsTrue(ProfOnSpine) ? Standard_True : Standard_False, - Tolerance); - TopoDS_Shape shape = evolved.Shape(); - return Py::new_reference_to(shape2pyshape(shape)); + try { + BRepOffsetAPI_MakeEvolved evolved(spine, profile, joinType, + PyObject_IsTrue(AxeProf) ? Standard_True : Standard_False, + PyObject_IsTrue(Solid) ? Standard_True : Standard_False, + PyObject_IsTrue(ProfOnSpine) ? Standard_True : Standard_False, + Tolerance); + TopoDS_Shape shape = evolved.Shape(); + return Py::new_reference_to(shape2pyshape(shape)); + } + catch (Standard_Failure& e) { + PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); + return nullptr; + } } PyObject* TopoShapeFacePy::valueAt(PyObject *args) diff --git a/src/Mod/Part/App/TopoShapeWirePyImp.cpp b/src/Mod/Part/App/TopoShapeWirePyImp.cpp index f00f3e2e7c..c48b6046b0 100644 --- a/src/Mod/Part/App/TopoShapeWirePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeWirePyImp.cpp @@ -309,10 +309,11 @@ PyObject* TopoShapeWirePy::makePipeShell(PyObject *args) } /* +import PartEnums v = App.Vector profile = Part.makePolygon([v(0.,0.,0.), v(-60.,-60.,-100.), v(-60.,-60.,-140.)]) spine = Part.makePolygon([v(0.,0.,0.), v(100.,0.,0.), v(100.,100.,0.), v(0.,100.,0.), v(0.,0.,0.)]) -evolve = spine.makeEvolved(profile) +evolve = spine.makeEvolved(Profile=profile, Join=PartEnums.JoinType.Arc) */ PyObject* TopoShapeWirePy::makeEvolved(PyObject *args, PyObject *kwds) { @@ -352,13 +353,19 @@ PyObject* TopoShapeWirePy::makeEvolved(PyObject *args, PyObject *kwds) break; } - BRepOffsetAPI_MakeEvolved evolved(spine, profile, joinType, - PyObject_IsTrue(AxeProf) ? Standard_True : Standard_False, - PyObject_IsTrue(Solid) ? Standard_True : Standard_False, - PyObject_IsTrue(ProfOnSpine) ? Standard_True : Standard_False, - Tolerance); - TopoDS_Shape shape = evolved.Shape(); - return Py::new_reference_to(shape2pyshape(shape)); + try { + BRepOffsetAPI_MakeEvolved evolved(spine, profile, joinType, + PyObject_IsTrue(AxeProf) ? Standard_True : Standard_False, + PyObject_IsTrue(Solid) ? Standard_True : Standard_False, + PyObject_IsTrue(ProfOnSpine) ? Standard_True : Standard_False, + Tolerance); + TopoDS_Shape shape = evolved.Shape(); + return Py::new_reference_to(shape2pyshape(shape)); + } + catch (Standard_Failure& e) { + PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); + return nullptr; + } } PyObject* TopoShapeWirePy::makeHomogenousWires(PyObject *args)