3
$\begingroup$

I'm trying to figure out how to create a filtered field like the ones found in the modifier and constraints panels that only allow you to select from a list of Armatures in the scene. Couldn't find where this type of property is defined for the existing UI panels.

$\endgroup$
1
  • $\begingroup$ Afaik its implemented in rna_object.c with object_poll family of functions. Also of interest are rna_modifiers.c and rna_constraints.c and the object_set functions. $\endgroup$
    – user2859
    Sep 22, 2014 at 18:08

1 Answer 1

2
$\begingroup$

For anyone having the same issue, it's as simple as using prop_search() instead of prop() in the draw code.

Example:

row.prop_search(bpy.context.scene, "your_string_prop", bpy.data, "armatures")

to create a filtered field for the armatures in your current scene.

$\endgroup$
1
  • 2
    $\begingroup$ Note that you're only able to store the datablock's name in a StringProperty(). The custom property won't change along with the Armature name! Properties that reference datablocks via pointers can't be created with Python. $\endgroup$
    – CodeManX
    Sep 22, 2014 at 18:44

You must log in to answer this question.

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