How to get mesh data with modifiers

When referring to the mesh geometry – its vertices, edges, and polygons, Blender operates with the original data without the usage of modifiers added to the object.

For example, the number of vertices of the active object, we can get with the following command:

And it will be returned without considering the object’s Subdivision modifier, which modifies the mesh’s geometry, increasing it.

So for a cube that has the Subdivision modifier added:

To get the object’s geometry, considering the modifiers that change it, we need to refer to the object through the “depsgraph” structure, which makes it possible to access the real state of the scene.

First, we need to get the “depsgraph” object for the current context:

Then, to get the “evaluated” version of the desired object, in which the effect of all modifiers has already been taken:

And through the evaluated object, get the geometry data.

We obtained the real data of the cube’s geometry like the Subdivision modifier was applied.

5 2 votes
Article Rating
Subscribe
Notify of
guest

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

Great. Now how do we apply that data back to the objects?