Page MenuHome"select", seq) does nothing
Closed, InvalidPublic


foreach_get returns a list of 0 and 1, but trying to set the select state doesn't select them in view

Blender 2.63 official

>>> ob_len = len(
>>> a = [None]*ob_len
>>>"select", a)
[0, 0, 1, 0, 1, 1]

>>> a = [1] * ob_len
>>>"select", a)
--> no change!



Event Timeline

Campbell, can you please look into this? Thanks :)

foreach_set is for low level data access, like setting vert locations in an array.
like the animation system, updates don't run here.


This task should not have been closed.
This is a bug and it would be nice to have fast access to the selection without have to use python iterators.

currently foreach_set('select', array) works for setting deselected vertices to selected.
However, it does not work for setting selected vertices to deselected.

I really think this should be looked at again.

Object selection state does not update in the viewport after calling foreach_set('select', array) even after updating with:


However properties such as show_all_edges and hide update in the viewport using the exact same update method.
It seems like a bug unless the select property requires some special update method the other properties don't.

I noticed common behavior while working through the foreach_get on vertices for their selection state. My sample code is as follows:

import bpy
import numpy as np

C = bpy.context
ob = C.object
num_vertices = len(
vertices_state = np.empty(num_vertices, dtype=bool)'select', vertices_state)

The above works only when the viewport shows object interaction mode as "Object Mode". When the view port shows "Edit Mode" then any selection (of vertices) made by the user is not visible by the above program unless the user goes to "Object Mode". Notice that you can always change the object interaction mode via bpy.ops.object.editmode_toggle(). Take a look at [1] and [2].