2
$\begingroup$

I'm developing a script where I need to retrieve the available values of some EnumProperties in Blender. I found a similar question already answered here. However, for some reason, this approach does not work with the property bpy.context.scene.render.engine.

Here is the code I am using, based on the provided answer by @ideasman42:

import bpy

def enum_members_from_type(rna_type, prop_str):
    prop = rna_type.bl_rna.properties[prop_str]
    return [e.identifier for e in prop.enum_items]

def enum_members_from_instance(rna_item, prop_str):
    return enum_members_from_type(type(rna_item), prop_str)

# Test the functions above:
enum = enum_members_from_instance(bpy.context.scene.render, "engine")
print(enum)

The problem is that it returns only this value:

['BLENDER_EEVEE']

I am expecting to get all possible render engine values like CYCLES, BLENDER_EEVEE, etc. Could anyone help me understand why this is happening and how I can retrieve all possible values for bpy.context.scene.render.engine?

Thank you!

Additional Information:

  • Blender Version: 4.1.0 (also tried 3.5)
  • OS: Windows 11
$\endgroup$
2
  • 2
    $\begingroup$ This can help: blender.stackexchange.com/questions/284383/… $\endgroup$
    – X Y
    Commented Jun 20 at 3:43
  • $\begingroup$ The script you provided does not work for builtin enums unfortunately. You can use either of the suggested answers. I don't know of any other way apart from hardcoding it $\endgroup$
    – Gorgious
    Commented Jun 21 at 15:11

0

Browse other questions tagged .