Is it possible to somehow search all objects on the scene which have a custom property enabled using prop_search?
I know how to do this with dynamic EnumProperty but it seems to be not an option as it has some bugs.
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
Since Blender 2.79 this possible by using
bpy.props.PointerProperty and its
# define the filter method def filter_on_custom_prop(self, object): return "MyCustomPropName" in object # define the property by using the bpy.props.PointerProperty and its poll function bpy.types.Object.my_object = bpy.props.PointerProperty( type=bpy.types.Object, poll=filter_on_custom_prop ) # add to your draw code a `prop_search` layout.prop_search(obj, "my_object", context.scene, "objects") # or just simple layout.prop(obj, "my_object")
After looking at the API, it doesn't appear to be possible.
From the API:
prop_search(data, property, search_data, search_property, text="", text_ctxt="", translate=True, icon='NONE')
property are the same as with a normal property. This may be like
search_data is the data to search in for the "property"
search_propertyis the property to look for in the data
With regards to the last two, it would be, e.g.,
I think a filtering technique like this would be better suited to the examples that @CoDEmanX shows in this answer: