From ec0c8f509e12c7b62f88fe63c666370d998518e2 Mon Sep 17 00:00:00 2001 From: CyrilWaechter Date: Sat, 10 Dec 2022 19:44:28 +0100 Subject: [PATCH] Move boundary origin to space origin Ensure that boundary origin is same as space origin to assign correct geometry into IFC. --- .../blenderbim/bim/module/boundary/operator.py | 1 + src/blenderbim/blenderbim/tool/boundary.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/boundary/operator.py b/src/blenderbim/blenderbim/bim/module/boundary/operator.py index 3b29c51e88..33ce113dc7 100644 --- a/src/blenderbim/blenderbim/bim/module/boundary/operator.py +++ b/src/blenderbim/blenderbim/bim/module/boundary/operator.py @@ -285,6 +285,7 @@ class UpdateBoundaryGeometry(bpy.types.Operator): return IfcStore.execute_ifc_operator(self, context) def _execute(self, context): + tool.Boundary.move_origin_to_space_origin(context.active_object) settings = tool.Boundary.get_assign_connection_geometry_settings(context.active_object) ifcopenshell.api.run("boundary.assign_connection_geometry", tool.Ifc.get(), **settings) return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/tool/boundary.py b/src/blenderbim/blenderbim/tool/boundary.py index d8c8cda521..5756b89e3d 100644 --- a/src/blenderbim/blenderbim/tool/boundary.py +++ b/src/blenderbim/blenderbim/tool/boundary.py @@ -62,3 +62,12 @@ class Boundary(blenderbim.core.tool.Boundary): def polyline_to_2d(cls, polyline, placement_matrix): matrix_inv = placement_matrix.inverted() return tuple((matrix_inv @ v).to_2d() for v in polyline) + + @classmethod + def move_origin_to_space_origin(cls, obj): + model = tool.Ifc.get() + boundary = tool.Ifc.get_entity(obj) + space = tool.Ifc.get_object(boundary.RelatingSpace) + translation = obj.matrix_world.translation - space.matrix_world.translation + obj.data.transform(mathutils.Matrix.Translation(translation)) + obj.matrix_world = space.matrix_world