How to get a list with all possible values of an EnumProperty

To correctly set values to an EnumProperty type we need to know all its possible entries.

If we try to set a value to an EnumProperty that is out of its available variants, Blender will throw an error:

TypeError: bpy_struct: item.attr = val: enum “xxx” not found in (‘value_001′, value_002’, …)

where:

xxx – the value we tried to set to an EnumProperty

value_001, value_002, … – possible EnumProperty values

The list of available EnumProperty values can be obtained through its rna-structure.

Let’s define a function that will return a list of possible EnumProperty values, with the object and enumerated property name obtained in its input parameters:

For example, let’s get all possible coordinate systems of the scene:

or all possible mesh modes:

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments