From eff778d5becfe96b2e0cda4a7695d7c17faccfb7 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 15 Jul 2024 15:00:36 +0500 Subject: [PATCH] support pythonocc >= 7.8.0 #4942 Related: https://github.com/tpaviot/pythonocc-core/issues/1350 Also added a print so this type of errors won't go silently. --- .../ifcopenshell/geom/occ_utils.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py index 7d879acfc5..2b230a4168 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py @@ -240,11 +240,15 @@ def create_shape_from_serialization(brep_object): return shape_tuple(brep_object, None, styles, style_ids) try: - ss = BRepTools.BRepTools_ShapeSet() - ss.ReadFromString(brep_data) - occ_shape = ss.Shape(ss.NbShapes()) - except BaseException: - pass + if OCC.VERSION < "7.8": + ss = BRepTools.BRepTools_ShapeSet() + ss.ReadFromString(brep_data) + occ_shape = ss.Shape(ss.NbShapes()) + else: + ss = BRepTools.breptools() + occ_shape = ss.ReadFromString(brep_data) + except BaseException as e: + print("Error occurred parsing a shape from a string:", e) if is_product_shape: return shape_tuple(brep_object, occ_shape, styles, style_ids)