Groups/Systems UI - removing item to update uilist index

This commit is contained in:
Andrej730
2025-09-15 12:32:56 +05:00
parent a3b04997ef
commit 6469f79343
4 changed files with 14 additions and 2 deletions
@@ -118,6 +118,7 @@ class RemoveGroup(bpy.types.Operator, tool.Ifc.Operator):
self.file = tool.Ifc.get()
ifcopenshell.api.group.remove_group(self.file, group=self.file.by_id(self.group))
tool.Group.import_groups("IfcGroup")
tool.Group.update_uilist_index("IfcGroup")
return {"FINISHED"}
@@ -87,7 +87,7 @@ class RemoveSystem(bpy.types.Operator, tool.Ifc.Operator):
system: bpy.props.IntProperty()
def _execute(self, context):
core.remove_system(tool.Ifc, tool.System, system=tool.Ifc.get().by_id(self.system))
core.remove_system(tool.Ifc, tool.Group, tool.System, system=tool.Ifc.get().by_id(self.system))
class EnableEditingSystem(bpy.types.Operator):
+7 -1
View File
@@ -55,9 +55,15 @@ def edit_system(ifc: type[tool.Ifc], system_tool: type[tool.System], system: ifc
system_tool.import_systems()
def remove_system(ifc: type[tool.Ifc], system_tool: type[tool.System], system: ifcopenshell.entity_instance) -> None:
def remove_system(
ifc: type[tool.Ifc],
group: type[tool.Group],
system_tool: type[tool.System],
system: ifcopenshell.entity_instance,
) -> None:
ifc.run("system.remove_system", system=system)
system_tool.import_systems()
group.update_uilist_index("IfcSystem")
def enable_editing_system(system_tool: type[tool.System], system: ifcopenshell.entity_instance) -> None:
+5
View File
@@ -137,3 +137,8 @@ class Group(bonsai.core.tool.System):
expanded_groups.remove(ifc_definition_id)
props.expanded_groups_json = json.dumps(list(expanded_groups))
cls.import_groups(group_type)
@classmethod
def update_uilist_index(cls, group_type: GroupType) -> None:
props, blender_groups = cls.get_groups_data(group_type)
props.active_group_index = tool.Blender.get_valid_uilist_index(props.active_group_index, blender_groups)