use get_shape_matrix util function where it's possible

This commit is contained in:
Andrej730
2024-06-10 15:22:15 +05:00
parent 51f859d8e4
commit de80e416c3
3 changed files with 10 additions and 17 deletions
@@ -823,14 +823,8 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator):
settings = ifcopenshell.geom.settings() settings = ifcopenshell.geom.settings()
shape = ifcopenshell.geom.create_shape(settings, opening) shape = ifcopenshell.geom.create_shape(settings, opening)
m = shape.transformation.matrix m = shape.transformation.matrix
mat = Matrix( mat = Matrix(ifcopenshell.util.shape.get_shape_matrix(shape))
( mat.translation = (0, 0, 0)
[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],
)
)
opening_bm = bmesh.new() opening_bm = bmesh.new()
verts = ifcopenshell.util.shape.get_vertices(shape.geometry) verts = ifcopenshell.util.shape.get_vertices(shape.geometry)
for vert in verts: for vert in verts:
@@ -1024,8 +1018,8 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator):
settings.set("disable-opening-subtractions", True) settings.set("disable-opening-subtractions", True)
# geometry = ifcopenshell.geom.create_shape(settings, body) # geometry = ifcopenshell.geom.create_shape(settings, body)
shape = ifcopenshell.geom.create_shape(settings, element) shape = ifcopenshell.geom.create_shape(settings, element)
m = shape.transformation.matrix mat = Matrix(ifcopenshell.util.shape.get_shape_matrix(shape))
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.translation = (0, 0, 0)
verts = [space_matrix_i @ mat @ Vector(v) for v in ifcopenshell.util.shape.get_vertices(shape.geometry)] 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) faces = ifcopenshell.util.shape.get_faces(shape.geometry)
polygons = [] polygons = []
@@ -30,6 +30,7 @@ import ifcopenshell.util.selector
import ifcopenshell.util.geolocation import ifcopenshell.util.geolocation
import ifcopenshell.util.representation import ifcopenshell.util.representation
import ifcopenshell.util.element import ifcopenshell.util.element
import ifcopenshell.util.shape
import blenderbim.bim.handler import blenderbim.bim.handler
import blenderbim.bim.schema import blenderbim.bim.schema
import blenderbim.tool as tool import blenderbim.tool as tool
@@ -1464,14 +1465,13 @@ class LoadLinkedProject(bpy.types.Operator):
def process_occurrence(self, shape: ShapeElementType) -> None: def process_occurrence(self, shape: ShapeElementType) -> None:
element = self.file.by_id(shape.id) element = self.file.by_id(shape.id)
matrix = shape.transformation.matrix
faces = shape.geometry.faces faces = shape.geometry.faces
verts = shape.geometry.verts verts = shape.geometry.verts
materials = shape.geometry.materials materials = shape.geometry.materials
material_ids = shape.geometry.material_ids material_ids = shape.geometry.material_ids
m = shape.transformation.matrix mat = ifcopenshell.util.shape.get_shape_matrix(shape)
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[:3, 3] = (0, 0, 0)
mesh = self.meshes.get(shape.geometry.id, None) mesh = self.meshes.get(shape.geometry.id, None)
if not mesh: if not mesh:
+3 -4
View File
@@ -39,6 +39,7 @@ import ifcopenshell.geom
import ifcopenshell.util.representation import ifcopenshell.util.representation
import ifcopenshell.util.element import ifcopenshell.util.element
import ifcopenshell.util.selector import ifcopenshell.util.selector
import ifcopenshell.util.shape
import blenderbim.bim.import_ifc import blenderbim.bim.import_ifc
import blenderbim.bim.module.drawing.sheeter as sheeter import blenderbim.bim.module.drawing.sheeter as sheeter
import blenderbim.bim.module.drawing.scheduler as scheduler import blenderbim.bim.module.drawing.scheduler as scheduler
@@ -694,10 +695,8 @@ class Drawing(blenderbim.core.tool.Drawing):
cls.import_camera_props(drawing, obj) cls.import_camera_props(drawing, obj)
tool.Ifc.link(drawing, obj) tool.Ifc.link(drawing, obj)
m = shape.transformation.matrix mat = Matrix(ifcopenshell.util.shape.get_shape_matrix(shape))
mat = mathutils.Matrix( mat.translation = (0, 0, 0)
([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])
)
obj.matrix_world = mat obj.matrix_world = mat
if cls.get_drawing_target_view(drawing) == "REFLECTED_PLAN_VIEW": if cls.get_drawing_target_view(drawing) == "REFLECTED_PLAN_VIEW":