From a358cff1b76dfa306dea4594767739566850328a Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 6 Mar 2025 18:34:52 +0500 Subject: [PATCH] Fix extrusion position update on OffsetFromReferenceLine changed #6255 Also fixed an issue when previously there was an offset and now it was set to 0 but slab did not reset it's position. --- src/bonsai/bonsai/bim/module/model/slab.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/slab.py b/src/bonsai/bonsai/bim/module/model/slab.py index 996536d8f6..cb6ba498a2 100644 --- a/src/bonsai/bonsai/bim/module/model/slab.py +++ b/src/bonsai/bonsai/bim/module/model/slab.py @@ -283,6 +283,7 @@ class DumbSlabPlaner: if tool.Model.get_usage_type(element) != "LAYER3": return layer_params = tool.Model.get_material_layer_parameters(element) + ifc_file = tool.Ifc.get() body_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW") obj = tool.Ifc.get_object(element) if not obj: @@ -326,9 +327,18 @@ class DumbSlabPlaner: extrusion.ExtrudedDirection.DirectionRatios = tuple(direction_ratios) extrusion.Depth = perpendicular_depth - if perpendicular_offset != 0.0 and not extrusion.Position: + ifc_position = extrusion.Position + if perpendicular_offset == 0.0: + # Clean up possible previous offset. + if ifc_position: + extrusion.Position = None + ifcopenshell.util.element.remove_deep2(ifc_file, ifc_position) + else: position = offset_direction * perpendicular_offset - tool.Model.add_extrusion_position(extrusion, position) + if ifc_position: + ifc_position.Location.Coordinates = position + else: + tool.Model.add_extrusion_position(extrusion, position) else: props = tool.Model.get_model_props()