Quickly apply all modifiers to the object

We can apply modifiers to an object by sequentially looping through the modifiers list and calling the bpy.ops.object.modifier_apply() operator to apply each of them. However, we can use the fact that the depsgraph already has fully calculated mesh data with modifiers already applied and simply rebuild the object according to this data.

The author of the method is Iyad Ahmed.

An additional bonus of this method is that we can apply modifiers both in the “Object” and in the “Edit” modes.

First, we need to get a pointer to the depsgraph:

with which we can now get the already fully calculated mesh geometry with all modifiers:

We will need to remove modifiers from the object later, which will affect the recalculated data, so we need to make a copy of the recalculated mesh geometry:

Now we can remove all modifiers from the object:

It remains to replace the current mesh geometry with the one that we previously saved.

For the “Object” mode:

and for the “Edit” mode:

As a result, we get the object with all modifiers applied to it.

Full code:

0 0 votes
Article Rating
Subscribe
Notify of
guest

2 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Andrej730
1 year ago

So basically it is the way to apply the modifiers without using bpy.ops! Is there downsides to this?