From 1f56b36bfa6bd84f4f7405bf1de69ac39ccabc59 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 4 Oct 2022 20:16:25 +1100 Subject: [PATCH] Minor fix --- .../api/geometry/add_axis_representation.py | 8 ++++++-- .../api/geometry/add_wall_representation.py | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py index ecb6870345..826e48494e 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py @@ -31,15 +31,19 @@ class Usecase: def execute(self): self.settings["unit_scale"] = ifcopenshell.util.unit.calculate_unit_scale(self.file) + is_2d = len(self.settings["axis"][0]) == 2 points = [self.convert_si_to_unit(p) for p in self.settings["axis"]] if self.file.schema == "IFC2X3": curve = self.file.createIfcPolyline([self.file.createIfcCartesianPoint(p) for p in points]) else: - curve = self.file.createIfcIndexedPolyCurve(self.file.createIfcCartesianPointList3D(points)) + if is_2d: + curve = self.file.createIfcIndexedPolyCurve(self.file.createIfcCartesianPointList2D(points), None, False) + else: + curve = self.file.createIfcIndexedPolyCurve(self.file.createIfcCartesianPointList3D(points), None, False) return self.file.createIfcShapeRepresentation( self.settings["context"], self.settings["context"].ContextIdentifier, - "Curve2D" if len(self.settings["axis"][0]) == 2 else "Curve3D", + "Curve2D" if is_2d else "Curve3D", [curve], ) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py index 29107e848a..a53864f553 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py @@ -47,16 +47,16 @@ class Usecase: length = self.convert_si_to_unit(self.settings["length"]) thickness = self.convert_si_to_unit(self.settings["thickness"]) points = ( - (0.0, 0.0, 0.0), - (0.0, thickness, 0.0), - (length, thickness, 0.0), - (length, 0.0, 0.0), - (0.0, 0.0, 0.0), + (0.0, 0.0), + (0.0, thickness), + (length, thickness), + (length, 0.0), + (0.0, 0.0), ) if self.file.schema == "IFC2X3": curve = self.file.createIfcPolyline([self.file.createIfcCartesianPoint(p) for p in points]) else: - curve = self.file.createIfcIndexedPolyCurve(self.file.createIfcCartesianPointList3D(points)) + curve = self.file.createIfcIndexedPolyCurve(self.file.createIfcCartesianPointList2D(points), None, False) extrusion = self.file.createIfcExtrudedAreaSolid( self.file.createIfcArbitraryClosedProfileDef("AREA", None, curve), self.file.createIfcAxis2Placement3D(