How to apply modifier on selected objects

To apply an object modifier with the Blender Python API we can use the “bpy.ops.object.modifier_apply” operator. However, it processes only the active object.

If we need to apply a modifier, for example – Subdivision Surface, to several selected objects, we need to make each of them active, and then call the “modifier_apply” operator.

Let’s loop through all the selected objects, make each of them active, and if the Subdivision Surface modifier is in the list of its modifiers, apply it.

If we need to apply a modifier of another type – change the type of the modifier in the condition:

We can get the type of the active modifier on the currently active object by executing the following code:

0 0 votes
Article Rating
Notify of
0 Comment
Inline Feedbacks
View all comments