From 73185293df2e720f101f5dacb4968be27a53c818 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 6 Dec 2024 12:35:01 +0500 Subject: [PATCH] Fix long time missing create_cog_representation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was used in the code but method wasn't defined. I believe it was lost during 8b7d968 😁 --- .../api/geometry/add_representation.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py index 82d9eac32e..3dae44410f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py @@ -955,6 +955,20 @@ class Usecase: [bounding_box], ) + def create_cog_representation(self) -> Union[ifcopenshell.entity_instance, None]: + mesh = self.settings["geometry"] + if not isinstance(mesh, bpy.types.Mesh) or len(verts := mesh.vertices) == 0: + return + vert = verts[0].co + cog = self.create_cartesian_point(vert.x, vert.y, vert.z) + return self.file.create_entity( + "IfcShapeRepresentation", + self.settings["context"], + self.settings["context"].ContextIdentifier, + "Point", + (cog,), + ) + def create_structural_reference_representation(self) -> ifcopenshell.entity_instance: if len(self.settings["geometry"].vertices) == 1: return self.file.createIfcTopologyRepresentation(