From ee2bedfb6488808c39ee2406c7dbf6cdb2ba0d45 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 24 Feb 2023 17:08:29 +0500 Subject: [PATCH] Update openings position based on fillings position at wall regenarete So basically now when you move windows or doors attached to the wall, their openings positions will also be updated if you hit "regenerate" for the wall. --- .../blenderbim/bim/module/model/wall.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/wall.py b/src/blenderbim/blenderbim/bim/module/model/wall.py index dfb0936cf6..f6fd0ac275 100644 --- a/src/blenderbim/blenderbim/bim/module/model/wall.py +++ b/src/blenderbim/blenderbim/bim/module/model/wall.py @@ -1167,10 +1167,13 @@ class DumbWallJoiner: "geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_body ) - if tool.Ifc.is_moved(obj): + wall_moved = tool.Ifc.is_moved(obj) + if wall_moved: # Openings should move with the host overall ... # ... except their position should stay the same along the local X axis of the wall - for opening in [r.RelatedOpeningElement for r in element.HasOpenings]: + for opening in [ + r.RelatedOpeningElement for r in element.HasOpenings if not r.RelatedOpeningElement.HasFillings + ]: percent = tool.Cad.edge_percent( self.body[0], (previous_origin, (previous_matrix @ Vector((1, 0, 0))).to_2d()) ) @@ -1183,8 +1186,21 @@ class DumbWallJoiner: else: coordinates[0] -= change_in_x opening.ObjectPlacement.RelativePlacement.Location.Coordinates = coordinates + blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj) + # If opening has filling then stick to the filling's position + # We're applying new openings position only after wall position is applied + for opening in [r.RelatedOpeningElement for r in element.HasOpenings if r.RelatedOpeningElement.HasFillings]: + filling_obj = tool.Ifc.get_object(opening.HasFillings[0].RelatedBuildingElement) + filling_moved = tool.Ifc.is_moved(filling_obj) + if filling_moved: + blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=filling_obj) + if filling_moved or wall_moved: + ifcopenshell.api.run( + "geometry.edit_object_placement", tool.Ifc.get(), product=opening, matrix=filling_obj.matrix_world + ) + blenderbim.core.geometry.switch_representation( tool.Ifc, tool.Geometry,