I'm trying to provide a tool for an artist on my gameDev project. They should be able to set a bunch of settings in a panel, and then press a button to start an automated export. I want to give let them set a bunch of boolean values, but I'm having trouble finding a good way to present a lot of booleans in the Blender UI.

UI Mockup:

I need to iterate over the values in each list, so having a BoolProperty for every checkbox is not an option.

I am not sure what kind of layout.prop would do this well, or what kind of property data structure to use with it.

On the UI side, prop_menu_enum() seems like it would be perfect...can I use it as to hold multiple UI checkboxes? Otherwise I could iterate over whatever kind of list of booleans I end up with and a property for each one.

On the data structure side, I see there is a BoolVectorProperty, but it doesn't seem to hold names for each value. There's a CollectionProperty, but I'm getting a error "TypeError: CollectionProperty(...): expected an RNA type derived from PropertyGroup, failed with type 'builin_function_or_method'" when I try to register a PropertyGroup that has a CollectionProperty as a member variable.

I keep getting the feeling that there's some good way to do this that I don't know about (and I know almost nothing about blender programming). Any recommendations?

  • $\begingroup$ You can use prop_menu_item to hold multiple UI checkboxes if you pass the ENUM_FLAG option to the corresponding EnumProperty. Don't specify the numids then. Blender uses powers of 2 for single elements and sums for combinations in this case. (bit field) $\endgroup$ Jul 24 '14 at 16:04

It works pretty well to use BoolVectorProperty and then in the UI to address each element by specifying the index and overriding the (empty) text. I learned this reading http://blenderartists.org/forum/archive/index.php/t-264624.html .


myList = ["cat", "rabbit", "fox"]

class SpriteSheetProperties(bpy.types.PropertyGroup):
    sets = bpy.props.BoolVectorProperty(
        name = "Sets",
        description = "Which animal sets to render",
        size = len(SETS),)

class SpritifyPanel(bpy.types.Panel):
    def draw(self, context):
        layout = self.layout

        box = layout.box()
        split = box.split(.25)
        column = split.column()
        for i,set in enumerate(SETS):
            column.row().prop(context.scene.spritesheet, 'sets', index=i, text=set)

Doing this over a few different list, I now have this nice box:

UI implemented

  • 3
    $\begingroup$ You can use column_flow if you don't want to split things manually. Other layout options are listed on the linked page. $\endgroup$ Jul 24 '14 at 15:46

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.