doc/python_api/rst/info_gotchas_meshes.rst
Modes and Mesh Access
When working with mesh data you may run into the problem where a script fails to run as expected in Edit-Mode. This is caused by Edit-Mode having its own data which is only written back to the mesh when exiting Edit-Mode.
A common example is that exporters may access a mesh through obj.data (a :class:bpy.types.Mesh)
when the user is in Edit-Mode, where the mesh data is available but out of sync with the edit mesh.
In this situation you can...
bmesh.types.BMesh.to_mesh.bmesh.from_edit_mesh... _info_gotcha_mesh_faces:
Since 2.63 n-gons are supported, this adds some complexity since in some cases you need to access triangles still (some exporters for example).
There are now three ways to access faces:
bpy.types.MeshPolygon --
this is the data structure which now stores faces in Object-Mode
(access as mesh.polygons rather than mesh.faces).bpy.types.MeshLoopTriangle --
the result of tessellating polygons into triangles
(access as mesh.loop_triangles).bmesh.types.BMFace --
the polygons as used in Edit-Mode.For the purpose of the following documentation, these will be referred to as polygons, loop triangles and BMesh-faces respectively.
Faces with five or more sides will be referred to as ngons.
.. list-table:: :header-rows: 1 :stub-columns: 1
bpy.types.MeshPolygonbpy.types.MeshLoopTrianglebmesh.types.BMFace.. note::
Using the :mod:bmesh API is completely separate API from :mod:bpy,
typically you would use one or the other based on the level of editing needed,
not simply for a different way to access faces.
All three data types can be used for face creation:
bpy.types.Mesh.loops which are a fixed array too.bmesh.types.BMesh uses more memory it can be managed by only operating on one mesh at a time.Editing is where the three data types vary most.
All three data types can be used for exporting, the choice mostly depends on whether the target format supports n-gons or not.