3
$\begingroup$

Is there any way to directly use Blender's object mode enum? Rather than having to "hard code" our own?

ActiveModes : EnumProperty(
    name = "Active Modes",
    options = {'ENUM_FLAG'},
    items = bpy.types.Object.mode,
    description = "x",
    default = {'OBJECT','POSE','SCULPT'},
    )

items = bpy.types.Object.mode is not valid.

I'm referring to this enum described in the 2.8 docs:

enum in [‘OBJECT’, ‘EDIT’, ‘POSE’, ‘SCULPT’, ‘VERTEX_PAINT’, ‘WEIGHT_PAINT’,
‘TEXTURE_PAINT’, ‘PARTICLE_EDIT’, ‘EDIT_GPENCIL’, ‘SCULPT_GPENCIL’,
‘PAINT_GPENCIL’, ‘WEIGHT_GPENCIL’], default ‘OBJECT’

Does anyone know of a way to access these items to reuse them?

Edit: I was able to find what I think is the definition of this list in Blender's source. If someone can some how use this to locate the python version, that would be great. Otherwise, if nothing else, at least it gives us quick access to the accurate display name strings:

const EnumPropertyItem rna_enum_workspace_object_mode_items[] = {
    {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
    {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
    {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
    {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
    {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
    {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
    {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
    {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
    {OB_MODE_EDIT_GPENCIL, "EDIT_GPENCIL", ICON_EDITMODE_HLT, "Grease Pencil Edit Mode", "Edit Grease Pencil Strokes"},
    {OB_MODE_SCULPT_GPENCIL, "SCULPT_GPENCIL", ICON_SCULPTMODE_HLT, "Grease Pencil Sculpt Mode", "Sculpt Grease Pencil Strokes"},
    {OB_MODE_PAINT_GPENCIL, "PAINT_GPENCIL", ICON_GREASEPENCIL, "Grease Pencil Draw", "Paint Grease Pencil Strokes"},
    {OB_MODE_WEIGHT_GPENCIL, "WEIGHT_GPENCIL", ICON_WPAINT_HLT, "Grease Pencil Weight Paint", "Grease Pencil Weight Paint Strokes"},
    {0, NULL, 0, NULL, NULL},
};

In case it matters, there is also another list/version, named rna_enum_object_mode_items that has slightly different mode names for Grease Pencil modes.

$\endgroup$

0

You must log in to answer this question.

Browse other questions tagged .