I have created and rigged a simple cartoon-style model. His facial expressions are really just an image sequence texture. This allows me to quickly change his facial expression by changing the "offset" value of the image sequence. Then I created a custom property and attached it to a driver. This system works well, but it would be nice to have friendly names like mouth_oo rather than trying to remember the numerical index.

Here is the code I have so far based on an article I read at blendersushi: http://pastebin.com/2aJWd2ZB. The trouble with this code seems to be that context.object.My_List never seems to be populated.

How can I create a custom property control for an object that updates the value of the driver, but gives me a user-friendly popup?

  • $\begingroup$ Modifying properties in draw() context is not allowed. Either use an operator to add items, or consider to use a dynamic EnumProperty instead. $\endgroup$
    – CodeManX
    Dec 17, 2014 at 10:52

1 Answer 1


Check this code, this shows you 2 different options:

One is with direct control over the index with a slider with changing labels, The other one is with the EnumProp like you have it.

enter image description here

import bpy

from bpy.props import EnumProperty

def updateEnumParameter(self, context):
    context.object.my_list_index = int(self.face)

class cls_IntFloatString(bpy.types.PropertyGroup):
    face_items =(("0","None","none"),
    face = bpy.props.EnumProperty(items=face_items, update=updateEnumParameter)


faces = {
    '0': "None",
    '1': "Smile",
    '2': "Content",
    '3': "Dizzy",
    '4': "Cat",
    '5': "Girl",
    '6': "Yuck",
    '7': "Macho",
    '8': "Pixel",
    '9': "Charming",
    '10': "Cry",
    '11': "Ouch",
    '12': "Ultraman"}

# Add these properties to every object in the entire Blender system
bpy.types.Object.my_list_index = bpy.props.IntProperty(min=0, max=len(faces)-1, default=0)
bpy.types.Object.my_list = bpy.props.PointerProperty(type=cls_IntFloatString)

class IntFloatStringPanel(bpy.types.Panel):
    bl_label = "Int Float String"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        box = layout.box()
        row = box.row()
        row.label("Selected Face:")
        row.prop(context.object, 'my_list_index', text=faces[str(context.object.my_list_index)], slider=True)
        box.prop(context.object.my_list, 'face', text='Selected Face')

def register():

def unregister():

if __name__ == "__main__":
  • $\begingroup$ Thank you, this worked like a charm! I very much appreciate your detailed working example. I have attached this to my driver and it works exactly as I hoped. Now I just need to find out how to move the panel to the 3D View properties shelf and my character will be ready to post on blendswap. :) $\endgroup$
    – tofarley
    Dec 17, 2014 at 22:04

You must log in to answer this question.

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