1
$\begingroup$

New scene.

Enter edit mode.

Use the bisect tool to slice the Cube.

Only the new vertices appear to be selected.

Enter object mode.

In the console:

# check what vertices are selected in the Cube mesh
verts = bpy.data.meshes['Cube'].vertices
for v in verts:
    if v.select:
        print(v)

<bpy_struct, MeshVertex at 0x0000021439A0ABD8>
<bpy_struct, MeshVertex at 0x0000021439A0ABEC>
<bpy_struct, MeshVertex at 0x0000021439A0AC00>
<bpy_struct, MeshVertex at 0x0000021439A0AC14>

# de-select all verts in the Cube mesh
for v in verts:
    v.select = False

# check to make sure they're de-selected     
for v in verts:
    if v.select:
         print(v)
# no vertices

# switch to edit mode         
bpy.ops.object.editmode_toggle()
{'FINISHED'}

# something is strange. vertices appear to be selected now.

# switch back to object mode
bpy.ops.object.editmode_toggle()
{'FINISHED'}

# look through each vert to see if it is selected
for v in verts:
    if v.select:
        print(v)
         
<bpy_struct, MeshVertex at 0x0000021439A098D8>
<bpy_struct, MeshVertex at 0x0000021439A098EC>
<bpy_struct, MeshVertex at 0x0000021439A09900>
<bpy_struct, MeshVertex at 0x0000021439A09914>

It seems like switching to edit mode selected vertices.
Except these are different objects than they originally were, despite being the same vertices.

Is this a bug? If not...what is going on? Why does selection get reported as one thing, and then revert to a prior state when switching to edit mode? How can the vertices displayed on screen be different objects each time they're reported? How can I prevent this?

$\endgroup$

1 Answer 1

3
$\begingroup$

4 edges are also selected.

Have noticed this too.

Remember that after the bisect as well as the four selected verts, there are 4 selected edges. Even though you deselect the verts, the edges aren't picking this up, so when re-enter edit mode the verts of the selected edges are selected.

To make sure nothing is selected deselect the lot.

Bmesh has a select flush for this, and now a select_set to validate selection.

How does Blender know which faces and edges to automatically select when doing a multi-vert selection?

PS. A copy of sorts of the mesh is created when entering edit mode, and written back when exiting.. or calling

ob.update_from_editmode()

hence the different memory ref.

EDIT re edit and unaccept.

An answer below says that this is happening because there are edges selected. And it doesn't happen if I use this same approach to select edges. However,

which at the time of posting can assume is this answer... test on plane (no geom selected, in OBJECT mode)

>>> ob = C.object
>>> me = ob.data
>>> C.mode
'OBJECT'

if I start from having no components selected  

>>> [v.select for v in me.vertices]
[False, False, False, False]

>>> [e.select for e in me.edges]
[False, False, False, False]

then select the same edges   Edge zero by way of example.

>>> me.edges[0].select = True
>>> [e.select for e in me.edges]
[True, False, False, False]

>>> [v.select for v in me.vertices]
[False, False, False, False]

then enter and exit edit mode,  

>>> bpy.ops.object.editmode_toggle()
{'FINISHED'}

>>> C.mode
'EDIT_MESH'

>>> bpy.ops.object.editmode_toggle()
{'FINISHED'}

>>> C.mode
'OBJECT'

the vertices remain unselected.

>>> [e.select for e in me.edges]
[True, False, False, False]

>>> [v.select for v in me.vertices]
[True, False, True, False]

So it's not just about having the edges selected.

Sure appears to be the case to me.

$\endgroup$
2
  • 1
    $\begingroup$ Was off finding that link, re "invalid select state" Came up against this the other day setting verts from UV. stackoverflow.com/a/66532648/5317130 IIRC this has changed behaviour and required a element wise deselection. Not aware of a simple flush like in bmesh. $\endgroup$
    – batFINGER
    Commented Mar 11, 2021 at 16:31
  • $\begingroup$ I was looking in the wrong place. This answer is correct. Also it illuminates the idiosyncrasy of the application altering what's selected when traversing modes. Which feels like a very large problem to me, but perhaps it will shake out. $\endgroup$ Commented Mar 16, 2021 at 3:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .