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))
This commit is contained in:
Andrej730
2024-09-23 14:07:06 +05:00
parent c6c9f400d3
commit 7e6be53237
+7 -2
View File
@@ -922,7 +922,10 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
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<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::SERIALIZED) {
IfcGeom::SerializedElement* serialization = new IfcGeom::SerializedElement(*brep);
@@ -952,7 +955,9 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
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<IfcUtil::IfcBaseEntity>()->id()), shapes);