Move boundary origin to space origin

Ensure that boundary origin is same as space origin to assign correct
geometry into IFC.
This commit is contained in:
CyrilWaechter
2022-12-10 19:44:28 +01:00
parent a23bac6ecb
commit ec0c8f509e
2 changed files with 10 additions and 0 deletions
@@ -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"}
@@ -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