To my knowledge I believe modifiers can moved up one step in the list through executing this line bpy.ops.object.modifier_move_up()

Is there anyway to move a modifier to the top of entire stack through python based on the modifier name or type ?


This can be done by some simple scripting. I assume obj is filled with the object with the modifier stack

def modifiers_by_name(obj, name):
    """ Find all modifiers with a specific name in obj """
    return [x for x in obj.modifiers if x.name == name]

def modifiers_by_type(obj, typename):
    """ Find all modifiers with a specific type in obj """
    return [x for x in obj.modifiers if x.type == typename]

# move all "Screw" modifiers to the top
for modifier in reversed(modifiers_by_type(obj, "SCREW")):
    # while modifier not on top
    while obj.modifiers.find(modifier.name) != 0:
        # move it one more to the top.

Note I reversed the modifiers so the top "Screw" modifier will still be on the top after execution


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.