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 ?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityTo 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.
bpy.ops.object.modifier_move_up(modifier=modifier.name)
Note I reversed the modifiers so the top "Screw" modifier will still be on the top after execution