From de80e416c38b0ff8962892f00655f3a3e3e1a6a2 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 10 Jun 2024 15:22:15 +0500 Subject: [PATCH] use get_shape_matrix util function where it's possible --- .../blenderbim/bim/module/boundary/operator.py | 14 ++++---------- .../blenderbim/bim/module/project/operator.py | 6 +++--- src/blenderbim/blenderbim/tool/drawing.py | 7 +++---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/boundary/operator.py b/src/blenderbim/blenderbim/bim/module/boundary/operator.py index 3375f02639..9abd8848ed 100644 --- a/src/blenderbim/blenderbim/bim/module/boundary/operator.py +++ b/src/blenderbim/blenderbim/bim/module/boundary/operator.py @@ -823,14 +823,8 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator): settings = ifcopenshell.geom.settings() shape = ifcopenshell.geom.create_shape(settings, opening) m = shape.transformation.matrix - mat = Matrix( - ( - [m[0], m[3], m[6], m[9]], - [m[1], m[4], m[7], m[10]], - [m[2], m[5], m[8], m[11]], - [0, 0, 0, 1], - ) - ) + mat = Matrix(ifcopenshell.util.shape.get_shape_matrix(shape)) + mat.translation = (0, 0, 0) opening_bm = bmesh.new() verts = ifcopenshell.util.shape.get_vertices(shape.geometry) for vert in verts: @@ -1024,8 +1018,8 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator): settings.set("disable-opening-subtractions", True) # geometry = ifcopenshell.geom.create_shape(settings, body) shape = ifcopenshell.geom.create_shape(settings, element) - m = shape.transformation.matrix - mat = Matrix(([m[0], m[3], m[6], m[9]], [m[1], m[4], m[7], m[10]], [m[2], m[5], m[8], m[11]], [0, 0, 0, 1])) + mat = Matrix(ifcopenshell.util.shape.get_shape_matrix(shape)) + mat.translation = (0, 0, 0) verts = [space_matrix_i @ mat @ Vector(v) for v in ifcopenshell.util.shape.get_vertices(shape.geometry)] faces = ifcopenshell.util.shape.get_faces(shape.geometry) polygons = [] diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index 7784f9f09b..a18467d331 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -30,6 +30,7 @@ import ifcopenshell.util.selector import ifcopenshell.util.geolocation import ifcopenshell.util.representation import ifcopenshell.util.element +import ifcopenshell.util.shape import blenderbim.bim.handler import blenderbim.bim.schema import blenderbim.tool as tool @@ -1464,14 +1465,13 @@ class LoadLinkedProject(bpy.types.Operator): def process_occurrence(self, shape: ShapeElementType) -> None: element = self.file.by_id(shape.id) - matrix = shape.transformation.matrix faces = shape.geometry.faces verts = shape.geometry.verts materials = shape.geometry.materials material_ids = shape.geometry.material_ids - m = shape.transformation.matrix - mat = np.array(([m[0], m[3], m[6], m[9]], [m[1], m[4], m[7], m[10]], [m[2], m[5], m[8], m[11]], [0, 0, 0, 1])) + mat = ifcopenshell.util.shape.get_shape_matrix(shape) + mat[:3, 3] = (0, 0, 0) mesh = self.meshes.get(shape.geometry.id, None) if not mesh: diff --git a/src/blenderbim/blenderbim/tool/drawing.py b/src/blenderbim/blenderbim/tool/drawing.py index 928e69ee7f..b17a1595ad 100644 --- a/src/blenderbim/blenderbim/tool/drawing.py +++ b/src/blenderbim/blenderbim/tool/drawing.py @@ -39,6 +39,7 @@ import ifcopenshell.geom import ifcopenshell.util.representation import ifcopenshell.util.element import ifcopenshell.util.selector +import ifcopenshell.util.shape import blenderbim.bim.import_ifc import blenderbim.bim.module.drawing.sheeter as sheeter import blenderbim.bim.module.drawing.scheduler as scheduler @@ -694,10 +695,8 @@ class Drawing(blenderbim.core.tool.Drawing): cls.import_camera_props(drawing, obj) tool.Ifc.link(drawing, obj) - m = shape.transformation.matrix - mat = mathutils.Matrix( - ([m[0], m[3], m[6], m[9]], [m[1], m[4], m[7], m[10]], [m[2], m[5], m[8], m[11]], [0, 0, 0, 1]) - ) + mat = Matrix(ifcopenshell.util.shape.get_shape_matrix(shape)) + mat.translation = (0, 0, 0) obj.matrix_world = mat if cls.get_drawing_target_view(drawing) == "REFLECTED_PLAN_VIEW":