From 7e6be53237240c4889d032c8d3442cd878aa17ed Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 23 Sep 2024 14:07:06 +0500 Subject: [PATCH] Improve error messages for shapes failed to process Example error messages now: RuntimeError: Failed to process shape. Product: #3855=IfcSite('3ZGD7y6S5209$mGLi_sPll',#20,'Surface:411452',$,$,#3854,#3850,$,.ELEMENT.,(42,12,46,799999),(-71,-2,0,-599999),0.,$,$), representation: #3849=IfcShapeRepresentation(#93,'FootPrint','Curve2D',(#3841,#31427,#31471,#45600,#45628)) RuntimeError: Failed to process shape. Instance: #3841=IfcPolyline((#3800,#3801,#3802,#3803,#3804,#3805,#3806,#3807,#3808,#3809,#3810,#3811,#3812,#3813,#3814,#3815,#3816,#3817,#3818,#3819,#3820,#3821,#3822,#3823,#3824,#3825,#3826,#3827,#3828,#3829,#3830,#3831,#3832,#3833,#3834,#3835,#3836,#3837,#3838,#3839,#3840,#3800)) --- src/ifcwrap/IfcGeomWrapper.i | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 322df42693..b953d8845a 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -922,7 +922,10 @@ struct ShapeRTTI : public boost::static_visitor IfcGeom::BRepElement* brep = kernel.create_brep_for_representation_and_product(ifc_representation, product); if (!brep) { - throw IfcParse::IfcException("Failed to process shape"); + std::ostringstream oss_repr, oss_product; + ifc_representation->toString(oss_repr); + product->toString(oss_product); + throw IfcParse::IfcException("Failed to process shape. Product: " + oss_product.str() + ", representation: " + oss_repr.str()); } if (settings.get().get() == ifcopenshell::geometry::settings::SERIALIZED) { IfcGeom::SerializedElement* serialization = new IfcGeom::SerializedElement(*brep); @@ -952,7 +955,9 @@ struct ShapeRTTI : public boost::static_visitor try { shapes = kernel.convert(instance); } catch (...) { - throw IfcParse::IfcException("Failed to process shape"); + std::ostringstream oss; + instance->toString(oss); + throw IfcParse::IfcException("Failed to process shape. Instance: " + oss.str()); } IfcGeom::Representation::BRep brep(settings, instance->declaration().name(), to_locale_invariant_string(instance->as()->id()), shapes);