In Blender, we can select and deselect mesh vertices through the “select” property for each vertex.
However, to deselect a vertex, it is not enough to set it’s “select” property to “False”
To deselect a vertex, first, we need to deselect polygons to which this vertex belongs and edges on which this vertex lies. And only after that, we can deselect the vertex itself.
For example, to deselect all mesh vertices, we need to execute the following code:
1 2 3 4 5 6 7 8 9 10 11 12 |
import bpy bpy.ops.object.mode_set(mode='OBJECT') for polygon in bpy.context.active_object.data.polygons: polygon.select = False for edge in bpy.context.active_object.data.edges: edge.select = False for vertex in bpy.context.active_object.data.vertices: vertex.select = False bpy.ops.object.mode_set(mode='EDIT') |
To work with the selection we must switch to the “OBJECT” mode, otherwise, selection changes will not be applied to the mesh.