Groups UI - support renaming groups directly from UI

Example - https://files.catbox.moe/u4b918.mp4
This commit is contained in:
Andrej730
2025-07-08 19:12:11 +05:00
parent 5866994b84
commit ad8d02bfed
3 changed files with 13 additions and 3 deletions
@@ -50,7 +50,7 @@ class LoadGroups(bpy.types.Operator, tool.Ifc.Operator):
def load_group(self, group: ifcopenshell.entity_instance, tree_depth: int = 0) -> None:
new = self.props.groups.add()
new.ifc_definition_id = group.id()
new.name = group.Name or "Unnamed"
new["name"] = group.Name or "Unnamed"
new.tree_depth = tree_depth
new.has_children = False
new.is_expanded = group.id() in self.expanded_groups
+11 -1
View File
@@ -38,8 +38,18 @@ def update_active_group_index(self, context):
refresh_pset()
def update_name(self: "Group", context: object) -> None:
group = tool.Ifc.get_entity_by_id(self.ifc_definition_id)
# Theoretically group can be removed outside Group UI.
if not group:
return
if group.Name == self.name:
return
group.Name = self.name
class Group(PropertyGroup):
name: StringProperty(name="Name")
name: StringProperty(name="Name", update=update_name)
ifc_definition_id: IntProperty(name="IFC Definition ID")
is_expanded: BoolProperty(name="Is Expanded", default=False)
has_children: BoolProperty(name="Has Children", default=False)
+1 -1
View File
@@ -141,4 +141,4 @@ class BIM_UL_groups(UIList):
op.ifc_definition_id = item.ifc_definition_id
op.index = index
op.option = "Collapse" if item.is_expanded else "Expand"
row.label(text=item.name)
row.prop(item, "name", text="", emboss=False)