Groups/Systems UI - expand parent group when child group is added

So user can immediately see the added item, it seems more intuitive.
This commit is contained in:
Andrej730
2025-09-15 12:36:23 +05:00
parent 6469f79343
commit 87069f3ac3
3 changed files with 7 additions and 4 deletions
@@ -87,9 +87,9 @@ class AddGroup(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
result = ifcopenshell.api.group.add_group(tool.Ifc.get())
if self.group:
ifcopenshell.api.group.assign_group(
tool.Ifc.get(), products=[result], group=tool.Ifc.get().by_id(self.group)
)
group = tool.Ifc.get().by_id(self.group)
ifcopenshell.api.group.assign_group(tool.Ifc.get(), products=[result], group=group)
tool.Group.toggle_group(group, "IfcGroup", "EXPAND")
tool.Group.import_groups("IfcGroup")
return {"FINISHED"}
@@ -67,7 +67,7 @@ class AddSystem(bpy.types.Operator, tool.Ifc.Operator):
props = tool.System.get_system_props()
ifc_file = tool.Ifc.get()
parent_system = None if self.parent_system_id == 0 else ifc_file.by_id(self.parent_system_id)
core.add_system(tool.Ifc, tool.System, ifc_class=props.system_class, parent_system=parent_system)
core.add_system(tool.Ifc, tool.Group, tool.System, ifc_class=props.system_class, parent_system=parent_system)
class EditSystem(bpy.types.Operator, tool.Ifc.Operator):
+3
View File
@@ -38,6 +38,7 @@ def disable_system_editing_ui(system: type[tool.System]) -> None:
def add_system(
ifc: type[tool.Ifc],
group: type[tool.Group],
system: type[tool.System],
ifc_class: str,
parent_system: Union[ifcopenshell.entity_instance, None],
@@ -45,6 +46,8 @@ def add_system(
new_system = ifc.run("system.add_system", ifc_class=ifc_class)
if parent_system:
ifc.run("group.assign_group", products=[new_system], group=parent_system)
group.toggle_group(parent_system, "IfcSystem", "EXPAND")
system.import_systems()