Limit "prop_search" to Specific Types of Objects Currently working on a piece of custom UI that contains an object selection box.

layout.prop_search(scene, "myselection", scene, "objects")


I'm wondering how I can make it so it only lists objects that contain a certain data type such as curves in the same way that the Follow Path constraint does.



Thanks for your assistance.
Since blender 2.79 this is possible using the poll parameter of the bpy.props.PointerProperty.

import bpy    

class OBJECT_PT_HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        layout.prop(scene, "mychosenObject")

def scene_mychosenobject_poll(self, object):
    return object.type == 'CURVE'

def register():
    bpy.utils.register_module(__name__)
    bpy.types.Scene.mychosenObject = bpy.props.PointerProperty(
        type=bpy.types.Object,
        poll=scene_mychosenobject_poll
    )


def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.Scene.mychosenObject


if __name__ == "__main__":
    register()


See the documentation 1

bpy.props.PointerProperty(type=None, name="", description="", options={'ANIMATABLE'}, poll=None, update=None)

Returns a new pointer property definition.
Parameters: 


type (class) – A subclass of bpy.types.PropertyGroup or bpy.types.ID.
name (string) – Name used in the user interface.
description (string) – Text used for the tooltip and api documentation.
options (set) – Enumerator in [‘HIDDEN’, ‘SKIP_SAVE’, ‘ANIMATABLE’, ‘LIBRARY_EDITABLE’, ‘PROPORTIONAL’,’TEXTEDIT_UPDATE’].
poll (function) – function to be called to determine whether an item is valid for this property. The function must take 2 values (self,object) and return Bool.
update (function) – Function to be called when this value is modified, This function must take 2 values (self, context) and return None. Warning there are no safety checks to avoid infinite recursion.