5
$\begingroup$

I have a simple object selector using a prop search. At the moment it runs but doesn't show any of the objects in my scene. This is what it looks like:

enter image description here

How can I get that to show all of my objects?

Here is my code, I've dug out only the parts that should concern it...hopefully

class IgnitProperties(bpy.types.PropertyGroup):

    screen_selector = StringProperty(
        name="",
        description = "Select the screen that goes with the unibody to rotate the screen properly!"
    )

    coll = CollectionProperty(
        type = bpy.types.PropertyGroup
    )

class IGLayoutDemoPanel(bpy.types.Panel):

    def draw(self, context):
        # Screen Selector
        layout.label(text = "Screen Selector:")
        layout.prop_search(scene.ignit_panel, "screen_selector", scene.ignit_panel, "coll", icon='OBJECT_DATA')
$\endgroup$

1 Answer 1

6
$\begingroup$

When using property search, you need to specify the collection of objects you want to search through in the 3rd and 4th parameters (in our case the list of objects in the active scene):

layout.prop_search(
    scene.ignit_panel,  # Object with your custom property
    "screen_selector",  # Your custom property
    context.scene,      # Object that contains the collection you want to search through 
    "objects"           # The collection property
)
$\endgroup$
1
  • 2
    $\begingroup$ Anyway to ask not Camera nor Lamps and only pick from Geometry? "objects" seems to inclusive. $\endgroup$ Commented Mar 26, 2018 at 2:29

You must log in to answer this question.

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