mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
Groups UI - support renaming groups directly from UI
Example - https://files.catbox.moe/u4b918.mp4
This commit is contained in:
@@ -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:
|
def load_group(self, group: ifcopenshell.entity_instance, tree_depth: int = 0) -> None:
|
||||||
new = self.props.groups.add()
|
new = self.props.groups.add()
|
||||||
new.ifc_definition_id = group.id()
|
new.ifc_definition_id = group.id()
|
||||||
new.name = group.Name or "Unnamed"
|
new["name"] = group.Name or "Unnamed"
|
||||||
new.tree_depth = tree_depth
|
new.tree_depth = tree_depth
|
||||||
new.has_children = False
|
new.has_children = False
|
||||||
new.is_expanded = group.id() in self.expanded_groups
|
new.is_expanded = group.id() in self.expanded_groups
|
||||||
|
|||||||
@@ -38,8 +38,18 @@ def update_active_group_index(self, context):
|
|||||||
refresh_pset()
|
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):
|
class Group(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name", update=update_name)
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
is_expanded: BoolProperty(name="Is Expanded", default=False)
|
is_expanded: BoolProperty(name="Is Expanded", default=False)
|
||||||
has_children: BoolProperty(name="Has Children", default=False)
|
has_children: BoolProperty(name="Has Children", default=False)
|
||||||
|
|||||||
@@ -141,4 +141,4 @@ class BIM_UL_groups(UIList):
|
|||||||
op.ifc_definition_id = item.ifc_definition_id
|
op.ifc_definition_id = item.ifc_definition_id
|
||||||
op.index = index
|
op.index = index
|
||||||
op.option = "Collapse" if item.is_expanded else "Expand"
|
op.option = "Collapse" if item.is_expanded else "Expand"
|
||||||
row.label(text=item.name)
|
row.prop(item, "name", text="", emboss=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user