I have found out that while it is possible to select vertices by setting select
to True, it is not possible to deselect vertices by setting select
to False if the vertices are already selected.
Sounds silly but it is not.
To demonstrate this, open a new file with the default cube, switch to Edit mode (all vertices should be selected by default).
Then run this script:
import bpy
bpy.ops.object.mode_set(mode="OBJECT")
bpy.data.meshes['Cube'].vertices[0].select = False
bpy.ops.object.mode_set(mode="EDIT")
The vertex 0 should be deselected, right? Well, it is not.
Now, deselect the top 4 vertices on the Cube and run this:
import bpy
bpy.ops.object.mode_set(mode="OBJECT")
bpy.data.meshes['Cube'].vertices[0].select = False
bpy.data.meshes['Cube'].vertices[5].select = True
bpy.ops.object.mode_set(mode="EDIT")
The vertex 5 will be a new selected one, as it should, but vertex 0 will still be selected but it should not be.
More info: if the select
property's value is checked while still in Object mode, it will be False. However, switching to Edit mode makes it back to True.
Why is deselecting vertices not working? Am I missing something?