API

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.

How to get scene data from the bpy.context

To have the access to the current context, for example, to work with operators, and to the scene data, for example, to work with meshes, we use two predefined structures from the Blender Python API: “bpy.context” and “bpy.data”.

For example, we can pass them to a function:

However, in the “bpy.context” structure there is a “blend_data” pointer that links to the scene data. With this pointer, we can access scene data without passing it separately and explicitly.