3

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.

  • 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. – user2859 Sep 22 '14 at 18:08

1 Answers1

2

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.

CodeManX
  • 29,298
  • 3
  • 89
  • 128
  • 2
    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. – CodeManX Sep 22 '14 at 18:44