[Bf-blender-cvs] [c0c3e83cec2] temp-attributes-panel: add support for adding and removing attributes

Jacques Lucke noreply at git.blender.org
Mon May 17 13:05:28 CEST 2021


Commit: c0c3e83cec22337f504456bfd3bfc32ca5f64f52
Author: Jacques Lucke
Date:   Mon May 17 13:04:44 2021 +0200
Branches: temp-attributes-panel
https://developer.blender.org/rBc0c3e83cec22337f504456bfd3bfc32ca5f64f52

add support for adding and removing attributes

===================================================================

M	release/scripts/startup/bl_ui/properties_data_mesh.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index c8c61bfbe29..f1efb59146f 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -581,6 +581,34 @@ class MESH_UL_attributes(UIList):
         sub.label(text=data_type.name)
 
 
+class MESH_MT_add_attribute(Menu):
+    bl_label = "Add Attribute"
+
+    @staticmethod
+    def add_standard_attribute(layout, mesh, name, data_type, domain):
+        exists = mesh.attributes.get(name) is not None
+
+        col = layout.column()
+        col.enabled = not exists
+        col.operator_context = 'EXEC_DEFAULT'
+
+        props = col.operator("geometry.attribute_add", text=name)
+        props.name = name
+        props.data_type = data_type
+        props.domain = domain
+
+    def draw(self, context):
+        layout = self.layout
+        mesh = context.mesh
+
+        self.add_standard_attribute(layout, mesh, 'scale', 'FLOAT_VECTOR', 'POINT')
+
+        layout.separator()
+
+        layout.operator_context = 'INVOKE_DEFAULT'
+        layout.operator("geometry.attribute_add", text="Custom...")
+
+
 class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel):
     bl_label = "Attributes"
     bl_options = {'DEFAULT_CLOSED'}
@@ -588,9 +616,12 @@ class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel):
 
     def draw(self, context):
         mesh = context.mesh
+
         layout = self.layout
+        row = layout.row()
 
-        layout.template_list(
+        col = row.column()
+        col.template_list(
             "MESH_UL_attributes",
             "attributes",
             mesh,
@@ -600,6 +631,11 @@ class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel):
             rows=3,
         )
 
+        col = row.column(align=True)
+        col.menu("MESH_MT_add_attribute", icon='ADD', text="")
+        col.operator("geometry.attribute_remove", icon='REMOVE', text="")
+
+
 
 classes = (
     MESH_MT_vertex_group_context_menu,
@@ -610,6 +646,7 @@ classes = (
     MESH_UL_uvmaps,
     MESH_UL_vcols,
     MESH_UL_attributes,
+    MESH_MT_add_attribute,
     DATA_PT_context_mesh,
     DATA_PT_vertex_groups,
     DATA_PT_shape_keys,



More information about the Bf-blender-cvs mailing list