From 051d5479fb90a7d257468399c4fc8d74beb72149 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 5 Sep 2024 11:16:22 +0500 Subject: [PATCH] Strip redundant newline in repr() for taxonomy items E.g. print([m.diffuse for m in shape.geometry.materials]) would print [colour 0.7 0.7 0.7 ] Instead of: [colour 0.7 0.7 0.7] --- src/ifcwrap/IfcGeomWrapper.i | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 4f18ee14c7..0f26e28db7 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -151,7 +151,14 @@ std::pair vector_to_buffer(const T& t) { std::string taxonomy_item_repr(ifcopenshell::geometry::taxonomy::item::ptr i) { std::ostringstream oss; i->print(oss); - return oss.str(); + std::string result = oss.str(); + + // Strip new line at the end of the printed result. + // result is probably always ends with \n but just to be safe. + if (!result.empty() && result.back() == '\n') { + result.pop_back(); + } + return result; } %}