From 44af4555c0646b04a021fcdd867c19fd4308c566 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 27 Apr 2024 08:20:29 +0200 Subject: [PATCH] Part: Create CompSolid/Compound/Shell if null before adding a sub-shape Creating a shape with Part.CompSolid(), Part.Compound() or Part.Shell() is a null shape. In order to allow to append sub-shapes with the add() method a valid shape must be created beforehand. This fixes #13208 --- src/Mod/Part/App/TopoShapeCompSolidPyImp.cpp | 4 ++++ src/Mod/Part/App/TopoShapeCompoundPyImp.cpp | 4 ++++ src/Mod/Part/App/TopoShapeShellPyImp.cpp | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/Mod/Part/App/TopoShapeCompSolidPyImp.cpp b/src/Mod/Part/App/TopoShapeCompSolidPyImp.cpp index 201c693441..67adae7183 100644 --- a/src/Mod/Part/App/TopoShapeCompSolidPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeCompSolidPyImp.cpp @@ -25,6 +25,7 @@ #ifndef _PreComp_ # include # include +# include # include #endif @@ -109,6 +110,9 @@ PyObject* TopoShapeCompSolidPy::add(PyObject* args) BRep_Builder builder; TopoDS_Shape comp = getTopoShapePtr()->getShape(); + if (comp.IsNull()) { + builder.MakeCompSolid(TopoDS::CompSolid(comp)); + } auto shapes = getPyShapes(obj); try { diff --git a/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp b/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp index 267f7b50c8..1a9ffcccc9 100644 --- a/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp @@ -30,6 +30,7 @@ # include # include # include +# include # include # include #endif @@ -103,6 +104,9 @@ PyObject* TopoShapeCompoundPy::add(PyObject *args) BRep_Builder builder; TopoDS_Shape comp = getTopoShapePtr()->getShape(); + if (comp.IsNull()) { + builder.MakeCompound(TopoDS::Compound(comp)); + } try { const TopoDS_Shape& sh = static_cast(obj)-> diff --git a/src/Mod/Part/App/TopoShapeShellPyImp.cpp b/src/Mod/Part/App/TopoShapeShellPyImp.cpp index 7e7e9a6e6d..389483103e 100644 --- a/src/Mod/Part/App/TopoShapeShellPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeShellPyImp.cpp @@ -140,6 +140,9 @@ PyObject* TopoShapeShellPy::add(PyObject *args) BRep_Builder builder; TopoDS_Shape shell = getTopoShapePtr()->getShape(); + if (shell.IsNull()) { + builder.MakeShell(TopoDS::Shell(shell)); + } try { const TopoShape& shape = *static_cast(obj)->getTopoShapePtr();