From c8939fa6d8fbe95b1dee315fbfe41c0bcdef3c6d Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 13 Oct 2021 17:52:34 +0200 Subject: [PATCH] String access of listofshape using regexp --- libsrc/occ/python_occ_shapes.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 43dfbec8..54f3f836 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1,6 +1,8 @@ #ifdef NG_PYTHON #ifdef OCCGEOMETRY +#include + #include <../general/ngpython.hpp> #include #include "../meshing/python_mesh.hpp" @@ -1551,9 +1553,10 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) .def("__getitem__",[](const ListOfShapes & self, string name) { ListOfShapes selected; + std::regex pattern(name); for (auto s : self) if (auto sname = OCCGeometry::global_shape_properties[s.TShape()].name) - if (sname == name) + if (std::regex_match(*sname, pattern)) selected.push_back(s); return selected; }, "returns list of all shapes named 'name'")