I'm trying to write and addon that will display modifiers in a listbox, with the selected modifiers settings displayed below. But can't accomplish it because the template_list function requires an active index to reference the selection, which doesn't exist in the case of modifiers. here's an example comparing the list for vertex groups and the list for modifiers.

The modifier list throws an error because as far as I know, there is no "active_index" for modifiers - their just in a static state. How can I assign an index to reference the individual modifiers and select them from the listbox to operate on them, such as changing properties? Could I use a custom property or is there a better way to do this?

The thing is, there must be an index because the list box ordering updates according to the modifier stack - I just need to know how to access it if possible, and pass it to the list box.

please be explicit because I'm no expert here, thanks.

    ob = bpy.context.object

    row = layout.row()
    row.template_list("MESH_UL_vgroups", "", ob, "vertex_groups", ob.vertex_groups,"active_index", rows=rows)

    row = layout.row()
    row.template_list("UI_UL_list", "list", ob, "modifiers",ob.modifiers, "active_index",rows=rows)

1 Answer 1


You can create a simple IntProperty() to be used as active index storage.

bpy.types.Object.modifier_active_index = bpy.props.IntProperty()

# ...

row.template_list("UI_UL_list", "list", ob, "modifiers", ob, "modifier_active_index", rows=rows)
  • $\begingroup$ should work, I'll have to cross reference the object.modifiers list to get the active selection. thanks! $\endgroup$
    – russcript
    Jul 4, 2014 at 20:06

You must log in to answer this question.

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