1

I am working on an add-on that lists the materials. We are looking for a way to display a large material preview using template_preview.

Although it was possible to display it, only the material drawn for the first time is displayed repeatedly. Even if only the material index number 3 is displayed, it seems to be affected by the first template_preview used.

template_preview should have been able to obtain the names of all material lists by mat.name.

How can I get a proper listing in template_preview? Also, can I view larger material previews in a better way?

enter image description here

''' python

def draw(self, context):
    layout = self.layout
    materials = [mat for mat in bpy.data.materials]
    col = layout.column(align=True)

    if materials:
        for mat in materials:

            row = col.row()
            rowc = row.column(align=True)
            rowc.scale_y = .5

            # Material Preview
            rowc.template_preview(bpy.data.materials[mat.name], show_buttons=False)

            # Material Name
            rowc.label(text=mat.name)

            # Material Index "3" Preview
            rowc = row.column(align=True)
            rowc.scale_y = .5
            rowc.template_preview(bpy.data.materials[3], show_buttons=False)
            rowc.label(text="Material Index 3 Preview")

'''

Bookyakuno
  • 43
  • 1
  • 6
  • 1
    Seems like a bug. Here is the similar question and it's turn out that template_preview can render only one image at a time. Maybe it's possible to use template_icon_view instead but I have no idea how to do it exactly https://blender.stackexchange.com/questions/28614/how-to-display-texture-preview-on-a-custom-node – Lambdadelta Jul 12 '19 at 20:26
  • Devs are aware of this issue https://developer.blender.org/T46733 https://developer.blender.org/T28822 – Lambdadelta Jul 12 '19 at 21:56
  • Oops, I'm sorry that it was a bug. Thank you for answering. – Bookyakuno Jul 13 '19 at 01:23

0 Answers0