I need to create a searchable material dropdown that excludes grease pencil materials. However if I do it like this

row.prop_search(item, "material_selector", bpy.data, "materials")

then all the materials in scene get included in material dropdown. How can I give custom search elements to prop_search method instead of generic bpy.data?


1 Answer 1


Use a pointer property with a poll.

To distinguish a regular material from one for a gp object there is the handy attribute Material.is_grease_pencil

Similarly to https://blender.stackexchange.com/a/159155/15543 and using a poll method https://blender.stackexchange.com/a/101303/15543

Will narrow down the selection based and offer the same choices as the regular material drop down.

import bpy
from bpy.props import PointerProperty

def poll_material(self, material):
    return not material.is_grease_pencil

class TEST_PT_layout_panel(bpy.types.Panel):
    bl_label = "Prop Panels"
    bl_category = "Test Panel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        col.prop_search(scene, "prop", bpy.data, "materials")
        col.prop(scene, "prop")

def register():
    bpy.types.Scene.prop = PointerProperty(

def unregister():
    del bpy.types.Scene.prop
if __name__ == "__main__":

Kinda related:

How to populate UIList with all material slot in scene? 2.8

  • $\begingroup$ Never got notified about your comment here (coming from blender.stackexchange.com/a/203312/31447) after reading your answer. I feel honored, thanks! However, I guess I'm too grumpy for that and don't like the lazy peps just asking something... I honestly was in hope you would participate. Regarding python questions as well as flagging dupes the reality is that nothing really changed after the election -> your vote, duartes vote, my vote, which is a bit disappointing IMO. We will see, hopefully that will change. Cheers $\endgroup$
    – brockmann
    Nov 27, 2020 at 14:00

Not the answer you're looking for? Browse other questions tagged .