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$
  • $\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 '14 at 18:08
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$
  • 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 '14 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.