mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 03:33:48 +00:00
Support renaming materials by double clicking them in materials ui
Example - https://imgur.com/a/NXr6Ku2 Which is especially important for non-IfcMaterials as they currently don't have their own editing UI (besides when they are applied to some element).
This commit is contained in:
@@ -119,8 +119,18 @@ def get_contexts(self, context):
|
|||||||
return MaterialsData.data["contexts"]
|
return MaterialsData.data["contexts"]
|
||||||
|
|
||||||
|
|
||||||
|
def update_material_name(self: "Material", context: bpy.types.Context) -> None:
|
||||||
|
ifc_file = tool.Ifc.get()
|
||||||
|
name = self.name
|
||||||
|
material = ifc_file.by_id(self.ifc_definition_id)
|
||||||
|
if material.is_a("IfcMaterialLayerSet"):
|
||||||
|
material.LayerSetName = name
|
||||||
|
else:
|
||||||
|
material.Name = name
|
||||||
|
|
||||||
|
|
||||||
class Material(PropertyGroup):
|
class Material(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name", update=update_material_name)
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
is_category: BoolProperty(name="Is Category", default=False)
|
is_category: BoolProperty(name="Is Category", default=False)
|
||||||
is_expanded: BoolProperty(name="Is Expanded", default=False)
|
is_expanded: BoolProperty(name="Is Expanded", default=False)
|
||||||
|
|||||||
@@ -348,6 +348,9 @@ class BIM_PT_object_material(Panel):
|
|||||||
|
|
||||||
class BIM_UL_materials(UIList):
|
class BIM_UL_materials(UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
|
mprops = context.scene.BIMMaterialProperties
|
||||||
|
material_type = mprops.material_type
|
||||||
|
|
||||||
if item:
|
if item:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
|
|
||||||
@@ -363,7 +366,10 @@ class BIM_UL_materials(UIList):
|
|||||||
row.label(text=item.name)
|
row.label(text=item.name)
|
||||||
else:
|
else:
|
||||||
row.label(text="", icon="BLANK1")
|
row.label(text="", icon="BLANK1")
|
||||||
row.label(text=item.name, icon="MATERIAL")
|
if material_type == "IfcMaterialList":
|
||||||
|
row.label(text=item.name, icon="MATERIAL")
|
||||||
|
else:
|
||||||
|
row.prop(item, "name", text="", icon="MATERIAL", emboss=False)
|
||||||
|
|
||||||
row2 = row.row()
|
row2 = row.row()
|
||||||
row2.alignment = "RIGHT"
|
row2.alignment = "RIGHT"
|
||||||
|
|||||||
Reference in New Issue
Block a user