How to add an eyedropper functionality to
prop_search in my addon?
col.prop_search(scene, "string_property", context.scene, "objects")
This code will create
prop_search just like on the animation below, but without an eyedropper.
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
I spoke to Campbell Barton (the developer who got eyedropper functionality implemented) about this, he said that this kind of functionality is not available in Python API at the moment.
Blender 2.79 now allows to create add-on properties which reference datablocks.
Using this property with a
prop_search() we'll get search box with an eyedropper.
prop_search() is not necessary, in this case
prop() will do just fine.
Noted by J. Bakker.
A working example based on answers given.
Given the struggles of How to draw Object selection with eyedropper layout using Python script here is an edit to the script from that question
Puts a panel in the "scene" tab of the properties area.
import bpy from bpy.props import PointerProperty 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", context.scene, "objects") #or col.prop(scene, "prop") def register(): bpy.types.Scene.prop = PointerProperty(type=bpy.types.Object) bpy.utils.register_class(TEST_PT_layout_panel) def unregister(): bpy.utils.unregister_class(TEST_PT_layout_panel) if __name__ == "__main__": register()
See https://blender.stackexchange.com/a/101303/15543 re creating a poll method for the pointer to filter, for example, for objects of type armature in the scene.