1
$\begingroup$

Under the render settings in the bake panel there is a 'bake type' dropdown menu. Each of the options within this is enumerated, however I want to be able to add my own option to this drop-down box.

using:

bpy.types.CyclesRenderSettings.bake_type.__add__(my_tuple_item)

doesn't actually add anything to the menu, and the structure remains the same. Is adding to this property group allowed?

Would there be a better way of going about it (apart from editing the source code)?

Thanks

$\endgroup$
1
$\begingroup$

scene.cycles.bake_type is already registered as a property of the CyclesRenderSettings class. We can get the details of the enum from the class itself, or in the example below from the instance; scene.cycles.rna_type.properties("bake_type")

Add a new item to the enum property list and redefine the property with our appended list.

enter image description here

import bpy
from bpy.props import EnumProperty

context = bpy.context
scene = context.scene
prop = scene.cycles.rna_type.properties["bake_type"]
items = [(i.identifier, i.name, i.description, i.icon, i.value) 
              for i in prop.enum_items.values()]

# add one
if 'FOO' not in [i[0] for i in items]:
    items.append(('FOO', "Foo", "New Foo Item", 'NONE', 11))

    bpy.types.CyclesRenderSettings.bake_type = EnumProperty(
                                             name=prop.name,
                                             description=prop.description,
                                             default=prop.default,
                                             items=items)

Would need to append a draw method to the panel that recognises the new enum prop 'FOO'.

Note: could get some hassles if cycles code doesn't know what to do with your new bake_type.

$\endgroup$

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.