1
1

Compare commits

...

6 Commits

View File

@@ -567,6 +567,76 @@ class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
_property_type = bpy.types.Mesh
class MESH_UL_attributes(UIList):
def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index):
data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]
split = layout.split(factor=0.50)
split.emboss = 'NONE'
split.prop(attribute, "name", text="")
sub = split.row()
sub.alignment = 'RIGHT'
sub.active = False
sub.label(text="%s%s" % (attribute.domain.title(), 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'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
mesh = context.mesh
layout = self.layout
row = layout.row()
col = row.column()
col.template_list(
"MESH_UL_attributes",
"attributes",
mesh,
"attributes",
mesh.attributes,
"active_index",
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,
MESH_MT_shape_key_context_menu,
@@ -575,6 +645,8 @@ classes = (
MESH_UL_shape_keys,
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,
@@ -587,6 +659,7 @@ classes = (
DATA_PT_remesh,
DATA_PT_customdata,
DATA_PT_custom_props_mesh,
DATA_PT_mesh_attributes,
)
if __name__ == "__main__": # only for live edit.