Styles UI - support renaming styles by double click

Example - https://imgur.com/a/X7WBllz
This commit is contained in:
Andrej730
2024-07-08 14:50:18 +05:00
parent fd48f70ef1
commit 9690bfb1ed
3 changed files with 14 additions and 2 deletions
@@ -51,8 +51,13 @@ def get_reflectance_methods(self, context):
return StylesData.data["reflectance_methods"]
def update_style_name(self: "Style", context: bpy.types.Context) -> None:
style = tool.Ifc.get().by_id(self.ifc_definition_id)
tool.Style.rename_style(style, self.name)
class Style(PropertyGroup):
name: StringProperty(name="Name")
name: StringProperty(name="Name", update=update_style_name)
ifc_definition_id: IntProperty(name="IFC Definition ID")
total_elements: IntProperty(name="Total Elements")
style_classes: CollectionProperty(name="Style Classes", type=StrProperty)
@@ -265,7 +265,7 @@ class BIM_UL_styles(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
if item:
row = layout.row(align=True)
row.label(text=item.name)
row.prop(item, "name", text="", emboss=False)
if item.has_surface_colour:
row = row.row(align=True)
row.enabled = False
+7
View File
@@ -663,3 +663,10 @@ class Style(blenderbim.core.tool.Style):
tool.Loader.create_surface_style_with_textures(blender_material, rendering_style, texture_style)
else:
assert_never(style_type)
@classmethod
def rename_style(cls, style: ifcopenshell.entity_instance, name: str) -> None:
"""Rename style and related blender material."""
blender_material = tool.Ifc.get_object(style)
# Will implicitly update the style name using handler.
blender_material.name = name