I have an existing selection which I'd like to further isolate using Python scripting. In this instance the math is simply that if the X coordinate is greater than zero, it should be deselected.
I already have this code, which successfully selects half of the object:
import bpy obj = bpy.context.active_object bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_mode(type="VERT") bpy.ops.object.mode_set(mode = 'OBJECT') for i in range(len(obj.data.vertices)): if obj.data.vertices[i].co.x > 0: obj.data.vertices[i].select = True bpy.ops.object.mode_set(mode = 'EDIT')
If I change the
> to a
< and run the script, then it selects the rest of the object, so it does seem that selections are able to build upon each other.
If I change
False, I would expect selected areas matching the logic (
co.x > 0) to be deselected, since it is setting the
select property to false. However, this doesn't actually work. Running the script with
False instead of
True results in the selection being unchanged regardless of any conditions I set. It seems that nothing happens when I use
.select = False. There are no errors printed to the console or anything.
After finding this question, it seems that I'm not the only one with the problem, but the answers simply seem to indicate that this is impossible due to the way Blender works with selecting faces and edges. So, is it possible? Can we deselect all connected faces and edges of a vertex in a Python script so that we can deselect the vertex?