The mesh data is accessed in object mode and intended for compact storage, for more flexible mesh editing from python see bmesh.
Blender stores 4 main arrays to define mesh geometry.
Each polygon reference a slice in the loop array, this way, polygons do not store vertices or corner data such as UV’s directly, only a reference to loops that the polygon uses.
Mesh.loops, Mesh.uv_layers Mesh.vertex_colors are all aligned so the same polygon loop indices can be used to find the UV’s and vertex colors as with as the vertices.
To compare mesh API options see: NGons and Tessellation Faces
This example script prints the vertices and UV’s 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" % (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" % me.loops[loop_index].vertex_index)
print(" UV: %r" % uv_layer[loop_index].uv)
base classes — bpy_struct, ID
Mesh datablock defining geometric surfaces
Maximum angle between face normals that ‘Auto Smooth’ will operate on
Type : | float in [-inf, inf], default 0.0 |
---|
Adjust active object’s texture space automatically when transforming object
Type : | boolean, default False |
---|
Edges of the mesh
Type : | MeshEdges bpy_prop_collection of MeshEdge, (readonly) |
---|
True when used in editmode
Type : | boolean, default False, (readonly) |
---|
Loops of the mesh (polygon corners)
Type : | MeshLoops bpy_prop_collection of MeshLoop, (readonly) |
---|
Type : | IDMaterials bpy_prop_collection of Material, (readonly) |
---|
Type : | FloatProperties bpy_prop_collection of MeshFloatPropertyLayer, (readonly) |
---|
Type : | IntProperties bpy_prop_collection of MeshIntPropertyLayer, (readonly) |
---|
Type : | StringProperties bpy_prop_collection of MeshStringPropertyLayer, (readonly) |
---|
Polygons of the mesh
Type : | MeshPolygons bpy_prop_collection of MeshPolygon, (readonly) |
---|
Render/display the mesh with double or single sided lighting
Type : | boolean, default False |
---|
Display weights created for the Bevel modifier
Type : | boolean, default False |
---|
Display creases created for subsurf weighting
Type : | boolean, default False |
---|
Display UV unwrapping seams
Type : | boolean, default False |
---|
Display sharp edges, used with the EdgeSplit modifier
Type : | boolean, default False |
---|
Display selected edges using highlights in the 3D view and UV editor
Type : | boolean, default False |
---|
Display selected edge angle, using global values when set in the transform panel
Type : | boolean, default False |
---|
Display selected edge lengths, using global values when set in the transform panel
Type : | boolean, default False |
---|
Display the angles in the selected edges, using global values when set in the transform panel
Type : | boolean, default False |
---|
Display the area of selected faces, using global values when set in the transform panel
Type : | boolean, default False |
---|
Display the index numbers of selected vertices, edges, and faces
Type : | boolean, default False |
---|
Display all faces as shades in the 3D view and UV editor
Type : | boolean, default False |
---|
Display Freestyle edge marks, used with the Freestyle renderer
Type : | boolean, default False |
---|
Display Freestyle face marks, used with the Freestyle renderer
Type : | boolean, default False |
---|
Display face normals as lines
Type : | boolean, default False |
---|
Display vertex normals as lines
Type : | boolean, default False |
---|
Display statistical information about the mesh
Type : | boolean, default False |
---|
Draw weights in editmode
Type : | boolean, default False |
---|
All skin vertices
Type : | bpy_prop_collection of MeshSkinVertexLayer, (readonly) |
---|
All UV maps for tessellated faces (read-only, for use by renderers)
Type : | TessfaceUVTextures bpy_prop_collection of MeshTextureFaceLayer, (readonly) |
---|
All tessellated face colors (read-only, for use by renderers)
Type : | VertexColors bpy_prop_collection of MeshColorLayer, (readonly) |
---|
Tessellation faces of the mesh (derived from polygons)
Type : | MeshTessFaces bpy_prop_collection of MeshTessFace, (readonly) |
---|
Texture space location
Type : | float array of 3 items in [-inf, inf], default (0.0, 0.0, 0.0) |
---|
Texture space size
Type : | float array of 3 items in [-inf, inf], default (0.0, 0.0, 0.0) |
---|
Selected edge count in editmode
Type : | int in [0, inf], default 0, (readonly) |
---|
Selected face count in editmode
Type : | int in [0, inf], default 0, (readonly) |
---|
Selected vertex count in editmode
Type : | int in [0, inf], default 0, (readonly) |
---|
Treat all set-smoothed faces with angles less than the specified angle as ‘smooth’ during render
Type : | boolean, default False |
---|
Adjust active object’s texture space automatically when transforming object
Type : | boolean, default False |
---|
Type : | boolean, default False |
---|
Type : | boolean, default False |
---|
Type : | boolean, default False |
---|
Use topology based mirroring (for when both sides of mesh have matching, unique topology)
Type : | boolean, default False |
---|
X Axis mirror editing
Type : | boolean, default False |
---|
Face selection masking for painting
Type : | boolean, default False |
---|
Vertex selection masking for painting (weight paint only)
Type : | boolean, default False |
---|
UV loop layer to be used as cloning source
Type : | MeshUVLoopLayer |
---|
Clone UV loop layer index
Type : | int in [0, inf], default 0 |
---|
UV loop layer to mask the painted area
Type : | MeshUVLoopLayer |
---|
Mask UV loop layer index
Type : | int in [0, inf], default 0 |
---|
All UV loop layers
Type : | UVLoopLayers bpy_prop_collection of MeshUVLoopLayer, (readonly) |
---|
UV map to be used as cloning source
Type : | MeshTexturePolyLayer |
---|
Clone UV map index
Type : | int in [0, inf], default 0 |
---|
UV map to mask the painted area
Type : | MeshTexturePolyLayer |
---|
Mask UV map index
Type : | int in [0, inf], default 0 |
---|
All UV maps
Type : | UVTextures bpy_prop_collection of MeshTexturePolyLayer, (readonly) |
---|
All vertex colors
Type : | LoopColors bpy_prop_collection of MeshLoopColorLayer, (readonly) |
---|
Vertices of the mesh
Type : | MeshVertices bpy_prop_collection of MeshVertex, (readonly) |
---|
(readonly)
Transform mesh vertices by a matrix
Parameters: | matrix (float array of 16 items in [-inf, inf]) – Matrix |
---|
Calculate vertex normals
Calculate face tessellation (supports editmode too)
Calculate smooth groups from sharp edges
Return (poly_groups, groups): | |
---|---|
poly_groups, Smooth Groups, int array of 1 items in [-inf, inf] groups, Total number of groups, int in [0, inf] |
update
Parameters: |
|
---|
unit_test_compare
Parameters: | mesh (Mesh, (optional)) – Mesh to compare to |
---|---|
Returns: | Return value, String description of result of comparison |
Return type: | string, (never None) |
validate geometry, return True when the mesh has had invalid geometry corrected/removed
Parameters: | verbose (boolean, (optional)) – Verbose, Output information about the errors found |
---|---|
Returns: | Result |
Return type: | boolean |
Make a mesh from a list of vertices/edges/faces Until we have a nicer way to make geometry, use this.
Parameters: |
|
---|
Inherited Properties
Inherited Functions
References