shape.name return optional<string>

This commit is contained in:
Christopher Lackner 2022-01-20 17:03:16 +01:00
parent b6396c15c0
commit 1fbfc440ac

View File

@ -719,11 +719,11 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
return shape; return shape;
}, py::arg("name"), "sets 'name' property to all solids of shape") }, py::arg("name"), "sets 'name' property to all solids of shape")
.def_property("name", [](const TopoDS_Shape & self) { .def_property("name", [](const TopoDS_Shape & self) -> optional<string> {
if (auto name = OCCGeometry::global_shape_properties[self.TShape()].name) if (auto name = OCCGeometry::global_shape_properties[self.TShape()].name)
return *name; return *name;
else else
return string(); return nullopt;
}, [](const TopoDS_Shape & self, optional<string> name) { }, [](const TopoDS_Shape & self, optional<string> name) {
OCCGeometry::global_shape_properties[self.TShape()].name = name; OCCGeometry::global_shape_properties[self.TShape()].name = name;
}, "'name' of shape") }, "'name' of shape")