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?
1 Answer
$\begingroup$
$\endgroup$
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)