Apply Modifier using UI Panel Button

I’m learning Blender Python, and what I have so far is a UI Panel button for duplication, but I want to add one to apply the ‘array’ modifier, and be able to change its settings through the script as well.

the modifier_apply operator expects a modifer name, otherwise it doesn’t know which modifier you want to apply.

since a user can actually change the name of a modifier, a common best practice is to loop through modifiers and find them by type.

for example:

for m in context.active_object.modifiers:
    if m.type=='ARRAY':

of course, if you go that route you’ll need to make your own operator to put in your panel since the built-in object.modifier_apply operator doesn’t work that way.

1 Like

wait a second, modifiers_apply applies, the modifier, and modifiers_add adds one? also, thanks for your help in this, as I also want to apply it after changing some settings

bpy.ops.object.modifier_apply (modifier = [Name] )


bpy.ops.object.modifier_apply (name = [Name] )

1 Like