2
$\begingroup$

For example in the following case, the Armature modifier should have a position index of 0 and the Subdivision a position index of 1. How can I get this index?

enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

Blender's collections don't support indexing (although support could be added).

So the simplest way is to convert to a list:

index = list(ob.modifiers).index(mod)

If you need to access indices multiple times you could create a table:

modifier_index_map = {mod: i for (i, mod) in enumerate(ob.modifiers)}

index = modifier_index_map[modifier]

If your not sure the modifier is in the map:

index_or_none = modifier_index_map.get(modifier)
$\endgroup$

You must log in to answer this question.

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