From c7105a22e6bcfead0d6ebc2b3a08d4227d398f21 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 3 Apr 2023 18:26:55 +0500 Subject: [PATCH] Fixed validation error for ELEVATION_VIEW curves #2925 Error occured because ShapeBuilder was assigning "Curve2D" representation type for elevation view curves when the correct type is "Curve3D". It use to occur for both doors and windows created with ifc modifier. ``` Validation error text: 2023-04-03:18:21:28,879 ERROR [rule_executor.py:154] On instance: #135=IfcShapeRepresentation(#21,'Profile','Curve2D',(#134)) Rule IfcShapeRepresentation_CorrectItemsForType: (IfcShapeRepresentationTypes(self.RepresentationType,self.Items)) Violated by: False + where False = IfcShapeRepresentationTypes('Curve2D', (#134=IfcIndexedPolyCurve(#133,(IfcLineIndex((1,2)),IfcLineIndex((2,3)),IfcLineIndex((3,4)),IfcLineIndex((4,1))),$),)) + where 'Curve2D' = #135=IfcShapeRepresentation(#21,'Profile','Curve2D',(#134)).RepresentationType + and (#134=IfcIndexedPolyCurve(#133,(IfcLineIndex((1,2)),IfcLineIndex((2,3)),IfcLineIndex((3,4)),IfcLineIndex((4,1))),$),) = #135=IfcShapeRepresentation(#21,'Profile','Curve2D',(#134)).Items ``` --- .../ifcopenshell/util/shape_builder.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py b/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py index d0d8126e8f..ce63aa5a76 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py +++ b/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py @@ -191,6 +191,7 @@ class ShapeBuilder: "Ref: https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcArbitraryClosedProfileDef.htm#8.15.3.1.4-Formal-propositions" ) import traceback + traceback.print_stack() if inner_curves: @@ -204,6 +205,7 @@ class ShapeBuilder: "Ref: https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcArbitraryClosedProfileDef.htm#8.15.3.1.4-Formal-propositions" ) import traceback + traceback.print_stack() profile = self.file.createIfcArbitraryProfileDefWithVoids( @@ -510,10 +512,18 @@ class ShapeBuilder: # < IfcShapeRepresentation if not isinstance(items, collections.abc.Iterable): items = [items] + + if items[0].is_a("IfcExtrudedAreaSolid"): + representation_type = "SweptSolid" + elif items[0].is_a("IfcCurve") and items[0].Dim == 3: + representation_type = "Curve3D" + else: + representation_type = "Curve2D" + representation = self.file.createIfcShapeRepresentation( ContextOfItems=context, RepresentationIdentifier=context.ContextIdentifier, - RepresentationType="SweptSolid" if items[0].is_a("IfcExtrudedAreaSolid") else "Curve2D", + RepresentationType=representation_type, Items=items, ) return representation