user: Describe Mesh Data from the Blender manual or Python API, including usage steps and snippets.

assistant: The mesh data is accessed in object mode and intended for compact storage,
for more flexible mesh editing from Python see [`bmesh`](bmesh.html#module-bmesh "bmesh").

Blender stores 4 main arrays to define mesh geometry.

- [`Mesh.vertices`](#bpy.types.Mesh.vertices "bpy.types.Mesh.vertices") (3 points in space)
- [`Mesh.edges`](#bpy.types.Mesh.edges "bpy.types.Mesh.edges") (reference 2 vertices)
- [`Mesh.loops`](#bpy.types.Mesh.loops "bpy.types.Mesh.loops") (reference a single vertex and edge)
- [`Mesh.polygons`](#bpy.types.Mesh.polygons "bpy.types.Mesh.polygons"): (reference a range of loops)

Each polygon references a slice in the loop array, this way,
polygons do not store vertices or corner data such as UVs directly,
only a reference to loops that the polygon uses.

[`Mesh.loops`](#bpy.types.Mesh.loops "bpy.types.Mesh.loops"), [`Mesh.uv_layers`](#bpy.types.Mesh.uv_layers "bpy.types.Mesh.uv_layers") [`Mesh.vertex_colors`](#bpy.types.Mesh.vertex_colors "bpy.types.Mesh.vertex_colors") are all aligned so the same polygon loop
indices can be used to find the UVs and vertex colors as with as the vertices.

To compare mesh API options see: [NGons and Tessellation Faces](info_gotchas_meshes.html#info-gotcha-mesh-faces)

This example script prints the vertices and UVs for each polygon, assumes the active object is a mesh with UVs.

```
import bpy

me = bpy.context.object.data
uv_layer = me.uv_layers.active.data

for poly in me.polygons:
    print("Polygon index: {:d}, length: {:d}".format(poly.index, poly.loop_total))

    # Range is used here to show how the polygons reference loops,
    # for convenience 'poly.loop_indices' can be used instead.
    for loop_index in range(poly.loop_start, poly.loop_start + poly.loop_total):
        print("    Vertex: {:d}".format(me.loops[loop_index].vertex_index))
        print("    UV: {!r}".format(uv_layer[loop_index].uv))
```

base classes — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct"), [`ID`](bpy.types.ID.html#bpy.types.ID "bpy.types.ID")

*class* bpy.types.Mesh(*ID*)
:   Mesh data-block defining geometric surfaces

    animation_data
    :   Animation data for this data-block

        Type:
        :   [`AnimData`](bpy.types.AnimData.html#bpy.types.AnimData "bpy.types.AnimData"), (readonly)

    attributes
    :   Geometry attributes

        Type:
        :   [`AttributeGroupMesh`](bpy.types.AttributeGroupMesh.html#bpy.types.AttributeGroupMesh "bpy.types.AttributeGroupMesh") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Attribute`](bpy.types.Attribute.html#bpy.types.Attribute "bpy.types.Attribute"), (readonly)

    auto_texspace
    :   Adjust active object’s texture space automatically when transforming object

        Type:
        :   boolean, default True

    color_attributes
    :   Geometry color attributes

        Type:
        :   [`AttributeGroupMesh`](bpy.types.AttributeGroupMesh.html#bpy.types.AttributeGroupMesh "bpy.types.AttributeGroupMesh") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Attribute`](bpy.types.Attribute.html#bpy.types.Attribute "bpy.types.Attribute"), (readonly)

    corner_normals
    :   The “slit” normal direction of each face corner, influenced by vertex normals, sharp faces, sharp edges, and custom normals. May be empty.

        Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshNormalValue`](bpy.types.MeshNormalValue.html#bpy.types.MeshNormalValue "bpy.types.MeshNormalValue"), (readonly)

    cycles
    :   Cycles mesh settings

        Type:
        :   `CyclesMeshSettings`, (readonly)

    edges
    :   Edges of the mesh

        Type:
        :   [`MeshEdges`](bpy.types.MeshEdges.html#bpy.types.MeshEdges "bpy.types.MeshEdges") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshEdge`](bpy.types.MeshEdge.html#bpy.types.MeshEdge "bpy.types.MeshEdge"), (readonly)

    has_custom_normals
    :   True if there is custom normal data for this mesh

        Type:
        :   boolean, default False, (readonly)

    is_editmode
    :   True when used in editmode

        Type:
        :   boolean, default False, (readonly)

    loop_triangle_polygons
    :   The face index for each loop triangle

        Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`ReadOnlyInteger`](bpy.types.ReadOnlyInteger.html#bpy.types.ReadOnlyInteger "bpy.types.ReadOnlyInteger"), (readonly)

    loop_triangles
    :   Tessellation of mesh polygons into triangles

        Type:
        :   [`MeshLoopTriangles`](bpy.types.MeshLoopTriangles.html#bpy.types.MeshLoopTriangles "bpy.types.MeshLoopTriangles") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshLoopTriangle`](bpy.types.MeshLoopTriangle.html#bpy.types.MeshLoopTriangle "bpy.types.MeshLoopTriangle"), (readonly)

    loops
    :   Loops of the mesh (face corners)

        Type:
        :   [`MeshLoops`](bpy.types.MeshLoops.html#bpy.types.MeshLoops "bpy.types.MeshLoops") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshLoop`](bpy.types.MeshLoop.html#bpy.types.MeshLoop "bpy.types.MeshLoop"), (readonly)

    materials
    :   Type:
        :   [`IDMaterials`](bpy.types.IDMaterials.html#bpy.types.IDMaterials "bpy.types.IDMaterials") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Material`](bpy.types.Material.html#bpy.types.Material "bpy.types.Material"), (readonly)

    normals_domain
    :   The attribute domain that gives enough information to represent the mesh’s normals

        Type:
        :   enum in [`'POINT'`, `'FACE'`, `'CORNER'`], default `'FACE'`, (readonly)

    polygon_normals
    :   The normal direction of each face, defined by the winding order and position of its vertices

        Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshNormalValue`](bpy.types.MeshNormalValue.html#bpy.types.MeshNormalValue "bpy.types.MeshNormalValue"), (readonly)

    polygons
    :   Polygons of the mesh

        Type:
        :   [`MeshPolygons`](bpy.types.MeshPolygons.html#bpy.types.MeshPolygons "bpy.types.MeshPolygons") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshPolygon`](bpy.types.MeshPolygon.html#bpy.types.MeshPolygon "bpy.types.MeshPolygon"), (readonly)

    radial_symmetry
    :   Number of mirrored regions around a central axis

        Type:
        :   int array of 3 items in [1, 64], default (1, 1, 1)

    remesh_mode
    :   - `VOXEL`
          Voxel – Use the voxel remesher.
        - `QUAD`
          Quad – Use the quad remesher.

        Type:
        :   enum in [`'VOXEL'`, `'QUAD'`], default `'VOXEL'`

    remesh_voxel_adaptivity
    :   Reduces the final face count by simplifying geometry where detail is not needed, generating triangles. A value greater than 0 disables Fix Poles.

        Type:
        :   float in [0, 1], default 0.0

    remesh_voxel_size
    :   Size of the voxel in object space used for volume evaluation. Lower values preserve finer details.

        Type:
        :   float in [0, inf], default 0.1

    shape_keys
    :   Type:
        :   [`Key`](bpy.types.Key.html#bpy.types.Key "bpy.types.Key"), (readonly)

    skin_vertices
    :   All skin vertices

        Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshSkinVertexLayer`](bpy.types.MeshSkinVertexLayer.html#bpy.types.MeshSkinVertexLayer "bpy.types.MeshSkinVertexLayer"), (readonly)

    texco_mesh
    :   Derive texture coordinates from another mesh

        Type:
        :   [`Mesh`](#bpy.types.Mesh "bpy.types.Mesh")

    texspace_location
    :   Texture space location

        Type:
        :   [`mathutils.Vector`](mathutils.html#mathutils.Vector "mathutils.Vector") of 3 items in [-inf, inf], default (0.0, 0.0, 0.0)

    texspace_size
    :   Texture space size

        Type:
        :   [`mathutils.Vector`](mathutils.html#mathutils.Vector "mathutils.Vector") of 3 items in [-inf, inf], default (1.0, 1.0, 1.0)

    texture_mesh
    :   Use another mesh for texture indices (vertex indices must be aligned)

        Type:
        :   [`Mesh`](#bpy.types.Mesh "bpy.types.Mesh")

    total_edge_sel
    :   Selected edge count in editmode

        Type:
        :   int in [0, inf], default 0, (readonly)

    total_face_sel
    :   Selected face count in editmode

        Type:
        :   int in [0, inf], default 0, (readonly)

    total_vert_sel
    :   Selected vertex count in editmode

        Type:
        :   int in [0, inf], default 0, (readonly)

    use_auto_texspace
    :   Adjust active object’s texture space automatically when transforming object

        Type:
        :   boolean, default True

    use_mirror_topology
    :   Use topology based mirroring (for when both sides of mesh have matching, unique topology)

        Type:
        :   boolean, default False

    use_mirror_vertex_groups
    :   Mirror the left/right vertex groups when painting. The symmetry axis is determined by the symmetry settings.

        Type:
        :   boolean, default True

    use_mirror_x
    :   Enable symmetry in the X axis

        Type:
        :   boolean, default False

    use_mirror_y
    :   Enable symmetry in the Y axis

        Type:
        :   boolean, default False

    use_mirror_z
    :   Enable symmetry in the Z axis

        Type:
        :   boolean, default False

    use_paint_bone_selection
    :   Bone selection during painting

        Type:
        :   boolean, default True

    use_paint_mask
    :   Face selection masking for painting

        Type:
        :   boolean, default False

    use_paint_mask_vertex
    :   Vertex selection masking for painting

        Type:
        :   boolean, default False

    use_remesh_fix_poles
    :   Produces fewer poles and a better topology flow

        Type:
        :   boolean, default False

    use_remesh_preserve_attributes
    :   Transfer all attributes to the new mesh

        Type:
        :   boolean, default False

    use_remesh_preserve_volume
    :   Projects the mesh to preserve the volume and details of the original mesh

        Type:
        :   boolean, default False

    uv_layer_clone
    :   UV loop layer to be used as cloning source

        Type:
        :   [`MeshUVLoopLayer`](bpy.types.MeshUVLoopLayer.html#bpy.types.MeshUVLoopLayer "bpy.types.MeshUVLoopLayer")

    uv_layer_clone_index
    :   Clone UV loop layer index

        Type:
        :   int in [0, inf], default 0

    uv_layer_stencil
    :   UV loop layer to mask the painted area

        Type:
        :   [`MeshUVLoopLayer`](bpy.types.MeshUVLoopLayer.html#bpy.types.MeshUVLoopLayer "bpy.types.MeshUVLoopLayer")

    uv_layer_stencil_index
    :   Mask UV loop layer index

        Type:
        :   int in [0, inf], default 0

    uv_layers
    :   All UV loop layers

        Type:
        :   [`UVLoopLayers`](bpy.types.UVLoopLayers.html#bpy.types.UVLoopLayers "bpy.types.UVLoopLayers") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshUVLoopLayer`](bpy.types.MeshUVLoopLayer.html#bpy.types.MeshUVLoopLayer "bpy.types.MeshUVLoopLayer"), (readonly)

    vertex_colors
    :   Legacy vertex color layers. Deprecated, use color attributes instead.

        Type:
        :   [`LoopColors`](bpy.types.LoopColors.html#bpy.types.LoopColors "bpy.types.LoopColors") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshLoopColorLayer`](bpy.types.MeshLoopColorLayer.html#bpy.types.MeshLoopColorLayer "bpy.types.MeshLoopColorLayer"), (readonly)

    vertex_normals
    :   The normal direction of each vertex, defined as the average of the surrounding face normals

        Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshNormalValue`](bpy.types.MeshNormalValue.html#bpy.types.MeshNormalValue "bpy.types.MeshNormalValue"), (readonly)

    vertices
    :   Vertices of the mesh

        Type:
        :   [`MeshVertices`](bpy.types.MeshVertices.html#bpy.types.MeshVertices "bpy.types.MeshVertices") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`MeshVertex`](bpy.types.MeshVertex.html#bpy.types.MeshVertex "bpy.types.MeshVertex"), (readonly)

    edge_creases
    :   Edge crease values for subdivision surface, corresponding to the “crease_edge” attribute.

        (readonly)

    edge_keys
    :   (readonly)

    vertex_creases
    :   Vertex crease values for subdivision surface, corresponding to the “crease_vert” attribute.

        (readonly)

    vertex_paint_mask
    :   Mask values for sculpting and painting, corresponding to the “.sculpt_mask” attribute.

        (readonly)

    transform(*matrix*, *\**, *shape_keys=False*)
    :   Transform mesh vertices by a matrix (Warning: inverts normals if matrix is negative)

        Parameters:
        :   - **matrix** ([`mathutils.Matrix`](mathutils.html#mathutils.Matrix "mathutils.Matrix") of 4 \* 4 items in [-inf, inf]) – Matrix
            - **shape_keys** (*boolean**,* *(**optional**)*) – Transform Shape Keys

    flip_normals()
    :   Invert winding of all polygons (clears tessellation, does not handle custom normals)

    set_sharp_from_angle(*\**, *angle=3.14159*)
    :   Reset and fill the “sharp_edge” attribute based on the angle of faces neighboring manifold edges

        Parameters:
        :   **angle** (*float in* *[**0**,* *3.14159**]**,* *(**optional**)*) – Angle, Angle between faces beyond which edges are marked sharp

    split_faces()
    :   Split faces based on the edge angle

    calc_tangents(*\**, *uvmap=''*)
    :   Compute tangents and bitangent signs, to be used together with the custom normals to get a complete tangent space for normal mapping (custom normals are also computed if not yet present)

        Parameters:
        :   **uvmap** (*string**,* *(**optional**,* *never None**)*) – Name of the UV map to use for tangent space computation

    free_tangents()
    :   Free tangents

    calc_loop_triangles()
    :   Calculate loop triangle tessellation (supports editmode too)

    calc_smooth_groups(*\**, *use_bitflags=False*, *use_boundary_vertices_for_bitflags=False*)
    :   Calculate smooth groups from sharp edges

        Parameters:
        :   - **use_bitflags** (*boolean**,* *(**optional**)*) – Produce bitflags groups instead of simple numeric values
            - **use_boundary_vertices_for_bitflags** (*boolean**,* *(**optional**)*) – Also consider different smoothgroups sharing only vertices (but without any common edge) as neighbors, preventing them from sharing the same bitflag value. Only effective when `use_bitflags` is set. WARNING: Will overflow (run out of available bits) easily with some types of topology, e.g. large fans of sharp edges

        Returns:
        :   `poly_groups`, Smooth Groups, int array of 1 items in [-inf, inf]

            `groups`, Total number of groups, int in [0, inf]

        Return type:
        :   (int array of 1 items in [-inf, inf], int in [0, inf])

    normals_split_custom_set(*normals*)
    :   Define custom normals of this mesh (use zero-vectors to keep auto ones)

        Parameters:
        :   **normals** (*float multi-dimensional array* *of* *1 \* 3 items in* *[**-1**,* *1**]*) – Normals

    normals_split_custom_set_from_vertices(*normals*)
    :   Define custom normals of this mesh, from vertices’ normals (use zero-vectors to keep auto ones)

        Parameters:
        :   **normals** (*float multi-dimensional array* *of* *1 \* 3 items in* *[**-1**,* *1**]*) – Normals

    update(*\**, *calc_edges=False*, *calc_edges_loose=False*)
    :   update

        Parameters:
        :   - **calc_edges** (*boolean**,* *(**optional**)*) – Calculate Edges, Force recalculation of edges
            - **calc_edges_loose** (*boolean**,* *(**optional**)*) – Calculate Loose Edges, Calculate the loose state of each edge

    update_gpu_tag()
    :   update_gpu_tag

    unit_test_compare(*\**, *mesh=None*, *threshold=7.1526e-06*)
    :   unit_test_compare

        Parameters:
        :   - **mesh** ([`Mesh`](#bpy.types.Mesh "bpy.types.Mesh"), (optional)) – Mesh to compare to
            - **threshold** (*float in* *[**0**,* *inf**]**,* *(**optional**)*) – Threshold, Comparison tolerance threshold

        Returns:
        :   Return value, String description of result of comparison

        Return type:
        :   string, (never None)

    clear_geometry()
    :   Remove all geometry from the mesh. Note that this does not free shape keys or materials.

    validate(*\**, *verbose=False*, *clean_customdata=True*)
    :   Validate geometry, return True when the mesh has had invalid geometry corrected/removed

        Parameters:
        :   - **verbose** (*boolean**,* *(**optional**)*) – Verbose, Output information about the errors found
            - **clean_customdata** (*boolean**,* *(**optional**)*) – Clean Custom Data, Remove temp/cached custom-data layers, like e.g. normals…

        Returns:
        :   Result

        Retu