Changing/adding new material preview render type

Greetings,

I’m no programer but I find my way through some scripts. Now, I have an idea that not many of you will see as necessary feature but I think that it would be an interesting add-on.
I was thinking about changing type of preview render in material properties box for cycles render, specifically the monkey head into something else, some custom made mesh but I can’t find the code describing any of the buttons for either monkey head or sphere or cube etc. I tried clicking “edit source” on right click menu and opened ui.py but it doesn’t mention any of the stuff.
So, is there anybody familiar with this part of the ui code? Just a hint on where to find these meshes so I can, hopefully, change it into something else.
Thanks

Milan

this is the function that displays the mesh.

layout.template_preview(bpy.context.active_object.active_material)

this is a template, which is code that is written mostly in c, source code.

bpy.context.active_object.active_material.preview_render_type=‘MONKEY’

the mesh is an enum which is a list that is defined in rna_material.c
“FLAT”
“SPHERE”
“CUBE”
“MONKEY”
“HAIR”
“SPHERE_A”

source\blender\makesrna\intern\rna_material.c

    static EnumPropertyItem preview_type_items[] = {
        {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"},
        {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Sphere"},
        {MA_CUBE, "CUBE", ICON_MATCUBE, "Cube", "Cube"},
        {MA_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Monkey"},
        {MA_HAIR, "HAIR", ICON_HAIR, "Hair", "Hair strands"},
        {MA_SPHERE_A, "SPHERE_A", ICON_MAT_SPHERE_SKY, "World Sphere", "Large sphere with sky"},
        {0, NULL, 0, NULL, NULL}

source\blender\editors\interface\interface_templates.c

so you got to edit the source code, or proposal.

display active_object mesh or display custom mesh.

That is exactly what I needed. Thanks. There’s just one thing that keeps me from doing this. I can’t find any of the files you mentioned (rna_material.c, nor interface_templat es.c) in Blender install dir. Is there some open version that i should download or am I not getting it right? …sorry for being such a noobie :slight_smile:

to download and compile blender: http://wiki.blender.org/index.php/Dev:Doc/Building_Blender

You also have to mess with startup.blend (I think that’s the right one) since the preview ‘types’ are different scenes in that file… which then gets compiled into blender.

You could probably just modify a local copy of the original startup.blend and test it out by messing with the “Monkey” scene (totally guessing btw).