2

I want to use new UI icons in some addons, But actually I get all the Old ones

enter image description here

change the Icons is easy, but this get the Old one

row.operator("view3d.nn", text="Sculpt", icon = "BRUSH_INFLATE")

I thought I was missing something, then I call the template_ID_preview, but this return the Old icon too.

paint = context.tool_settings.sculpt
layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)

**** update*

Actually I use the icon_value from 0 to 5000 but the result is the same old UI icons

        row = layout.row()
    icons = bpy.types.UILayout.bl_rna.functions["prop"].parameters["icon"].enum_items.keys()
    c=0
    while c != 5000:
        print(icons[c])
        c+=1


        row.label(text= str(c), icon_value =c)

        if c%10 ==0:
            row = layout.row()
            row = row.row(align=True)

old fashion UI icons what I'm missing?

yhoyo
  • 2,285
  • 13
  • 32
  • Do you mean the colored versions with the blue bits in the tool panel? If so, those are custom icons and you have to use icon_value = and find their icon id value, rather than icon = in the call to row.operator – Marty Fouts Feb 01 '22 at 00:59
  • @MartyFouts actually I test the icon_value from 0 to 5000 and the result is the same old icons.... the maximum icon_value with some result is 818. – yhoyo Feb 01 '22 at 02:09

1 Answers1

2

To use the custom brush icons, you need to import and use an undocumented helper class. Here's an example that puts a pane in the object data properties using the 'draw' icon:

import bpy
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper

class PreviewsExamplePanel(bpy.types.Panel): """Creates a Panel in the Object properties window""" bl_label = "Previews Example Panel" bl_idname = "OBJECT_PT_previews" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "object" def draw(self, context): layout = self.layout #pcoll = icons_dict["draw"] row = layout.row() #my_icon = pcoll["draw"] #row.operator("render.render", text="", icon_value=my_icon.icon_id) icon_id = ToolSelectPanelHelper._icon_value_from_icon_handle('brush.sculpt.draw') row.operator("render.render", text="", icon_value=icon_id)

def register(): bpy.utils.register_class(PreviewsExamplePanel)

def unregister(): bpy.utils.unregister_class(PreviewsExamplePanel)

if name == "main": register()

That produces:

Previews Example Panel

You can find all of the custom tool icons using this code, adapted from How to get toolbar icons names on devtalk

icons = []

cls = ToolSelectPanelHelper._tool_class_from_space_type('VIEW_3D') for item_group in cls.tools_from_context(bpy.context): if type(item_group) is tuple: index_current = cls._tool_group_active.get(item_group[0].idname, 0) for sub_item in item_group: print(sub_item.label) icons.append(sub_item.icon) else: if item_group is not None: print(item_group.label) icons.append(item_group.icon)

Marty Fouts
  • 33,070
  • 10
  • 35
  • 79