# How to get modifier position?

I need to check if the modifier.name for example "Subdivison" on the top of the modifiers stack

if modifier.name position == 0:
print('Modifier "Subdivison" at the beginning of the stack')
else:
print('Modifier "Subdivison" somewhere in the stack')


something like this

• Hi, @APEC.. could you repost your solution as an answer, and accept it, so folks know not to try again, and others know where to find it in future? Thanks Aug 3 '21 at 11:36
• @RobinBetts: not apecs fault, i copied the solution in it ;) Aug 3 '21 at 11:38
• I ask Chris to make a post and edit my original message. And then I accept it as a solution. Sorry for inconvenience.
– APEC
Aug 3 '21 at 11:38
• Cheers, all, for whatever it is you're up to :D Aug 3 '21 at 11:39

check this out:

The modifiers are just sorted in an array where the first is on position 0, the second on position 1 and so on.

import bpy

for o in bpy.context.scene.objects:
if o.type == 'MESH':
if o.modifiers:
if o.modifiers[0].type == "SOLIDIFY":
print("solidify modifier is on top for", o.name)


shorter version for python shorties.... ;)

tops = [o for o in bpy.context.scene.objects
if o.type == 'MESH' and o.modifiers
and o.modifiers[0].type == "SOLIDIFY"]

for o in tops:
print("solidify modifier is on top for", o.name)

• What if name contain *.001. *.002 so with if "Subdivison" in modifier.name. For example I apply a modifier and I need if it on the top then print: 1, if somewhere in the stack, then print: 2
– APEC
Aug 3 '21 at 11:40
• if you apply a modifier, it will be deleted from the array and i cannot be on top anymore. Aug 3 '21 at 11:41
• @APEC: i am not sure what you mean, can you give a bit more explained example? what name? objects name? modifiers name? i don't understand, sorry. Aug 3 '21 at 11:43
• Hmmmm... :) Aug 3 '21 at 11:45
• never mind, all fine! Thank you!
– APEC
Aug 3 '21 at 11:48