user: How do I use Base Mesh Type in Blender? Include parameters, examples, warnings and best practices.

assistant: *class* bmesh.types.BMesh
:   The BMesh data structure

    calc_loop_triangles()
    :   Calculate triangle tessellation from quads/ngons.

        Returns:
        :   The triangulated faces.

        Return type:
        :   list[tuple[[`bmesh.types.BMLoop`](#bmesh.types.bmesh.types.BMLoop "bmesh.types.bmesh.types.BMLoop"), [`bmesh.types.BMLoop`](#bmesh.types.bmesh.types.BMLoop "bmesh.types.bmesh.types.BMLoop"), [`bmesh.types.BMLoop`](#bmesh.types.bmesh.types.BMLoop "bmesh.types.bmesh.types.BMLoop")]]

    calc_volume(*\**, *signed=False*)
    :   Calculate mesh volume based on face normals.

        Parameters:
        :   **signed** (*bool*) – when signed is true, negative values may be returned.

        Returns:
        :   The volume of the mesh.

        Return type:
        :   float

    clear()
    :   Clear all mesh data.

    copy()
    :   Returns:
        :   A copy of this BMesh.

        Return type:
        :   [`bmesh.types.BMesh`](#bmesh.types.bmesh.types.BMesh "bmesh.types.bmesh.types.BMesh")

    free()
    :   Explicitly free the BMesh data from memory, causing exceptions on further access.

    from_mesh(*mesh*, *\**, *face_normals=True*, *vertex_normals=True*, *use_shape_key=False*, *shape_key_index=0*)
    :   Initialize this bmesh from existing mesh data-block.

        Parameters:
        :   - **mesh** ([`bpy.types.Mesh`](bpy.types.Mesh.html#bpy.types.Mesh "bpy.types.Mesh")) – The mesh data to load.
            - **use_shape_key** (*bool*) – Use the locations from a shape key.
            - **shape_key_index** (*int*) – The shape key index to use.

    from_object(*object*, *depsgraph*, *\**, *cage=False*, *face_normals=True*, *vertex_normals=True*)
    :   Initialize this bmesh from existing object data-block (only meshes are currently supported).

        Parameters:
        :   - **object** ([`bpy.types.Object`](bpy.types.Object.html#bpy.types.Object "bpy.types.Object")) – The object data to load.
            - **cage** (*bool*) – Get the mesh as a deformed cage.
            - **face_normals** (*bool*) – Calculate face normals.
            - **vertex_normals** (*bool*) – Calculate vertex normals.

    normal_update()
    :   Update normals of mesh faces and verts.

    select_flush(*select*)
    :   Flush selection from vertices, independent of the current selection mode.

        Parameters:
        :   **select** (*bool*) – flush selection or de-selected elements.

    select_flush_mode(*\**, *flush_down=False*)
    :   Flush selection based on the current mode current [`bmesh.types.BMesh.select_mode`](#bmesh.types.bmesh.types.BMesh.select_mode "bmesh.types.bmesh.types.BMesh.select_mode").

        Parameters:
        :   **flush_down** (*bool*) – Flush selection down from faces to edges & verts or from edges to verts. This option is ignored when vertex selection mode is enabled.

    to_mesh(*mesh*)
    :   Writes this BMesh data into an existing Mesh data-block.

        Parameters:
        :   **mesh** ([`bpy.types.Mesh`](bpy.types.Mesh.html#bpy.types.Mesh "bpy.types.Mesh")) – The mesh data to write into.

    transform(*matrix*, *\**, *filter=None*)
    :   Transform the mesh (optionally filtering flagged data only).

        Parameters:
        :   - **matrix** ([`mathutils.Matrix`](mathutils.html#mathutils.Matrix "mathutils.Matrix")) – 4x4x transform matrix.
            - **filter** (*set**[**Literal**[**'SELECT'**,* *'HIDE'**,* *'SEAM'**,* *'SMOOTH'**,* *'TAG'**]**]*) – Flag to filter vertices..

    uv_select_flush(*select*)
    :   Flush selection from UV vertices to edges & faces independent of the selection mode.

        Parameters:
        :   **select** (*bool*) – Flush selection or de-selected elements.

    uv_select_flush_mode(*\**, *flush_down=False*)
    :   Flush selection based on the current mode current `BMesh.select_mode`.

        Parameters:
        :   **flush_down** (*bool*) – Flush selection down from faces to edges & verts or from edges to verts. This option is ignored when vertex selection mode is enabled.

    uv_select_flush_shared(*select*)
    :   Flush selection from UV vertices to contiguous UV’s independent of the selection mode.

        Parameters:
        :   **select** (*bool*) – Flush selection or de-selected elements.

    uv_select_foreach_set(*select*, */*, *\**, *loop_verts=()*, *loop_edges=()*, *faces=()*, *sticky_select_mode='SHARED_LOCATION'*)
    :   Set the UV selection state for loop-vertices, loop-edges & faces.

        This is a close equivalent to selecting in the UV editor.

        Parameters:
        :   - **select** (*bool*) – The selection state to set.
            - **loop_verts** (Iterable[[`bmesh.types.BMLoop`](#bmesh.types.bmesh.types.BMLoop "bmesh.types.bmesh.types.BMLoop")]) – Loop verts to operate on.
            - **loop_edges** (Iterable[[`bmesh.types.BMLoop`](#bmesh.types.bmesh.types.BMLoop "bmesh.types.bmesh.types.BMLoop")]) – Loop edges to operate on.
            - **faces** (Iterable[[`bmesh.types.BMFace`](#bmesh.types.bmesh.types.BMFace "bmesh.types.bmesh.types.BMFace")]) – Faces to operate on.
            - **sticky_select_mode** (Literal[‘SHARED_LOCATION’, ‘DISABLED’, ‘SHARED_VERTEX’]) – See ([`bpy.types.ToolSettings.uv_sticky_select_mode`](bpy.types.ToolSettings.html#bpy.types.ToolSettings.uv_sticky_select_mode "bpy.types.ToolSettings.uv_sticky_select_mode") which may be passed in directly)..

    uv_select_foreach_set_from_mesh(*select*, */*, *\**, *verts=()*, *edges=()*, *faces=()*, *sticky_select_mode='SHARED_LOCATION'*)
    :   Select or de-select mesh elements, updating the UV selection.

        An equivalent to selecting from the 3D viewport for selection operations that support maintaining a synchronized UV selection.

        Parameters:
        :   - **select** (*bool*) – The selection state to set.
            - **verts** (Iterable[[`bmesh.types.BMVert`](#bmesh.types.bmesh.types.BMVert "bmesh.types.bmesh.types.BMVert")]) – Verts to operate on.
            - **edges** (Iterable[[`bmesh.types.BMEdge`](#bmesh.types.bmesh.types.BMEdge "bmesh.types.bmesh.types.BMEdge")]) – Edges to operate on.
            - **faces** (Iterable[[`bmesh.types.BMFace`](#bmesh.types.bmesh.types.BMFace "bmesh.types.bmesh.types.BMFace")]) – Faces to operate on.
            - **sticky_select_mode** (Literal[‘SHARED_LOCATION’, ‘DISABLED’, ‘SHARED_VERTEX’]) – See ([`bpy.types.ToolSettings.uv_sticky_select_mode`](bpy.types.ToolSettings.html#bpy.types.ToolSettings.uv_sticky_select_mode "bpy.types.ToolSettings.uv_sticky_select_mode") which may be passed in directly)..

    uv_select_sync_from_mesh(*\**, *sticky_select_mode='SHARED_LOCATION'*)
    :   Sync selection from mesh to UVs.

        Parameters:
        :   **sticky_select_mode** (Literal[‘SHARED_LOCATION’, ‘DISABLED’, ‘SHARED_VERTEX’]) – Behavior when flushing from the mesh to UV selection ([`bpy.types.ToolSettings.uv_sticky_select_mode`](bpy.types.ToolSettings.html#bpy.types.ToolSettings.uv_sticky_select_mode "bpy.types.ToolSettings.uv_sticky_select_mode") which may be passed in directly).. This should only be used when preparing to create a UV selection.

    uv_select_sync_to_mesh()
    :   Sync selection from UVs to the mesh.

    edges
    :   This meshes edge sequence (read-only).

        Type:
        :   [`bmesh.types.BMEdgeSeq`](#bmesh.types.bmesh.types.BMEdgeSeq "bmesh.types.bmesh.types.BMEdgeSeq")

    faces
    :   This meshes face sequence (read-only).

        Type:
        :   [`bmesh.types.BMFaceSeq`](#bmesh.types.bmesh.types.BMFaceSeq "bmesh.types.bmesh.types.BMFaceSeq")

    is_valid
    :   True when this element is valid (hasn’t been removed).

        Type:
        :   bool

    is_wrapped
    :   True when this mesh is owned by blender (typically the editmode BMesh).

        Type:
        :   bool

    loops
    :   This meshes loops (read-only).

        Type:
        :   [`bmesh.types.BMLoopSeq`](#bmesh.types.bmesh.types.BMLoopSeq "bmesh.types.bmesh.types.BMLoopSeq")

    select_history
    :   Sequence of selected items (the last is displayed as active).

        Type:
        :   [`bmesh.types.BMEditSelSeq`](#bmesh.types.bmesh.types.BMEditSelSeq "bmesh.types.bmesh.types.BMEditSelSeq")

    select_mode
    :   The selection mode, cannot be assigned an empty set.

        Type:
        :   set[Literal[‘VERT’, ‘EDGE’, ‘FACE’]]

    uv_select_sync_valid
    :   When true, the UV selection has been synchronized. Setting to False means the UV selection will be ignored. While setting to true is supported it is up to the script author to ensure a correct selection state before doing so.
        :type: bool

    verts
    :   This meshes vert sequence (read-only).

        Type:
        :   [`bmesh.types.BMVertSeq`](#bmesh.types.bmesh.types.BMVertSeq "bmesh.types.bmesh.types.BMVertSeq")