diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index 83946d4c0d..bc54335c91 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -811,6 +811,7 @@ class ChangeExtrusionDepth(bpy.types.Operator, tool.Ifc.Operator): if layer2_objs: tool.Model.recalculate_walls(layer2_objs) + _resync_walls_after_mutation(layer2_objs) return {"FINISHED"} @@ -926,6 +927,7 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator): if layer2_objs: tool.Model.recalculate_walls(layer2_objs) + _resync_walls_after_mutation(layer2_objs) return {"FINISHED"} @@ -948,6 +950,7 @@ class ChangeLayerLength(bpy.types.Operator, tool.Ifc.Operator): selected_objs = tool.Model.get_selected_mesh_ifc_objects() for obj in selected_objs: joiner.set_length(obj, self.length) + _resync_walls_after_mutation(selected_objs) class OffsetWalls(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/bonsai/test/bim/module/model/test_wall_props_resync_on_dim_change.py b/src/bonsai/test/bim/module/model/test_wall_props_resync_on_dim_change.py new file mode 100644 index 0000000000..f9f05fb936 --- /dev/null +++ b/src/bonsai/test/bim/module/model/test_wall_props_resync_on_dim_change.py @@ -0,0 +1,57 @@ +# Bonsai - OpenBIM Blender Add-on +# Copyright (C) 2026 +# +# This file is part of Bonsai. +# +# Bonsai is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Bonsai is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Bonsai. If not, see . +# +# This file was generated with the assistance of an AI coding tool. + +"""Pins the contract that the three dimension-mutating wall operators — +``bim.change_extrusion_depth``, ``bim.change_extrusion_x_angle``, +``bim.change_layer_length`` — re-prime ``BIMWallProperties`` from the +post-mutation IFC at the end of ``_execute``. + +Without the resync, ``props.height`` / ``props.length`` / ``props.x_angle`` +stay at their pre-mutation values; gizmo icons that position from +``props.height`` then sit at the old elevation even though the wall mesh +shows the new one.""" + +import inspect + +import pytest + +pytestmark = pytest.mark.wall + + +def _execute_source(operator_cls): + return inspect.getsource(operator_cls._execute) + + +def test_change_extrusion_depth_resyncs_wall_props(): + from bonsai.bim.module.model.wall import ChangeExtrusionDepth + + assert "_resync_walls_after_mutation" in _execute_source(ChangeExtrusionDepth) + + +def test_change_extrusion_x_angle_resyncs_wall_props(): + from bonsai.bim.module.model.wall import ChangeExtrusionXAngle + + assert "_resync_walls_after_mutation" in _execute_source(ChangeExtrusionXAngle) + + +def test_change_layer_length_resyncs_wall_props(): + from bonsai.bim.module.model.wall import ChangeLayerLength + + assert "_resync_walls_after_mutation" in _execute_source(ChangeLayerLength)