1
$\begingroup$

This might be a noob question but I am trying to understand something regarding blender's api.

I was writing a script that part of it was to change the renderer to cycles, I was able to do that using bpy.data.scenes['Scene'].render.engine = 'CYCLES'

my question is: is there a way to see all the other variables I can use (like 'BLENDER_EEVEE' or 'BLENDER_WORKBENCH') without using blender's info workspace?

e.g. enter image description here

is it in the code itself or in the documentation? I can't seem to find it anywhere.

this might seems a bit silly for advanced users but I think it is a valid question. Thanks.

$\endgroup$
3

2 Answers 2

4
$\begingroup$

An easy way:

enter image description here

If you assign something that does not match ("XXX"), you'll have the list of available values.

$\endgroup$
1
$\begingroup$

To iterate on lemon's answer, here's an extremely hacky way to get the enum entries as strings :

import bpy

try:
    bpy.context.scene.render.engine = ""
except Exception as e:
    # TypeError: bpy_struct: item.attr = val: enum "" not found in ('BLENDER_EEVEE', 'BLENDER_WORKBENCH', 'CYCLES')
    # Parse the error, split the string and take every other result
    results = str(e).split("'")[1::2]
    print(results)

or as a function

import bpy


def enum_entries(data_name, data_prop_name):
    try:
        setattr(data_name, data_prop_name, "")
    except Exception as e:
        return str(e).split("'")[1::2]

print(enum_entries(bpy.context.scene.render, "engine"))
$\endgroup$
5
  • 1
    $\begingroup$ If luckily, "XXX" is not a possible value ;) $\endgroup$
    – lemon
    Commented Mar 7 at 14:40
  • $\begingroup$ @lemon Haha yeah you found the one and only Achilles heel of this solution >< $\endgroup$
    – Gorgious
    Commented Mar 7 at 14:42
  • 1
    $\begingroup$ That would be an awesome render engine name though. I wonder what it would be used for :p $\endgroup$
    – Gorgious
    Commented Mar 7 at 14:52
  • 1
    $\begingroup$ replacing twitwitwitter $\endgroup$
    – lemon
    Commented Mar 7 at 14:53
  • 1
    $\begingroup$ Haha thank you. You made me LOL in from of my screen at work. Now they know I'm browsing BSE x) $\endgroup$
    – Gorgious
    Commented Mar 7 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .