From 8beb1bef983ca3edd9ab930e3351226c3ec4917b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 23 Apr 2024 16:01:15 +0500 Subject: [PATCH] preserve selected profile index removing profiles --- src/blenderbim/blenderbim/bim/module/profile/operator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/profile/operator.py b/src/blenderbim/blenderbim/bim/module/profile/operator.py index 839e6a49ae..188cceaf26 100644 --- a/src/blenderbim/blenderbim/bim/module/profile/operator.py +++ b/src/blenderbim/blenderbim/bim/module/profile/operator.py @@ -66,9 +66,15 @@ class RemoveProfileDef(bpy.types.Operator, tool.Ifc.Operator): profile: bpy.props.IntProperty() def _execute(self, context): + props = context.scene.BIMProfileProperties + current_index = props.active_profile_index ifcopenshell.api.run("profile.remove_profile", tool.Ifc.get(), profile=tool.Ifc.get().by_id(self.profile)) bpy.ops.bim.load_profiles() + # preserve selected index if possible + if props.profiles: + props.active_profile_index = min(current_index, len(props.profiles) - 1) + class EnableEditingProfile(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.enable_editing_profile"