access to Material Browser Menu

Is it possible to get access to Material Browser Menu? The little Menu, that appears, if the Material Button is clicked. I want to use this for a Script.

Is there a Template, or do i have to rebuild it. If so, how do i get it? And otherwise, where do i get the specific icons for the Materials?

Thanks, Doc

you want to switch to the Material tab in properties area?

for area in bpy.context.screen.areas:
    if area.type == 'PROPERTIES':
        spaces[0].context = 'MATERIAL'
        # Without break, will change to material tab in all properties editors

You have to use the template_ID:
template_ID(data, property, new="", open="", unlink="")

There is also one that show a small preview of the material:
template_ID(data, property, new="", open="", unlink="")

To see an example, right-click on the material menu and select “Edit source”, the script will be available in the Text editor.

right-click on the material menu and select “Edit source”, the script will be available in the Text editor
That was a great Tip. Thank You. :slight_smile:
I found the Source to that Menu and used it. It works well, but i run into an other Problem.
I want to store the Result of that Menue in a List. I don’t know how.

Similar to:
List = []
List.append(Result from Menu)

It should not stored in the Objekt, as the Example from the Script does. Where can temporary Datas be stored, that they can be globaly accessed.

I tried such a Code:

layout.template_ID(MatList, MatList.nM)

class MatList(bpy.types.Operator):
    bl_idname = "wm.mat_list"    # bpy.ops.wm.mat_list()
    bl_label = "add Material"
    nM = bpy.props.StringProperty()
    global mL
    mL = []

    def execute(self, context):
        return {'FINISHED'}


That does not work. :frowning: I receive that Error:
TypeError: UILayout.template_ID(): error with argument 1, “data” - Function.dat a expected a AnyType type, not OrderedMeta

Can somebody help me and show me the Way?
Thank You.

afaik, you must store stuff in properties for template_id

what is your final goal?
maybe there are other ways to achieve what you want

The Goal is a List of Materials, chosen by the User. The script will make a couple of changes to them. It would be nice if i could use the Material Browser.
But i dont know which Object and Property are necessary. The Class in my Code above did not work. :frowning: