Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

May 17, 2011

Blender 2.5 Python 3.2 Determine Which Vertices are Selected

You select your vertices in Edit Mode, but for python to tell you what vertices are selected you must enter Object Mode.

import bpy
# need to be in object mode to do this operation, you could place a check here and
# switch, but that is extra work!
for i in bpy.context.active_object.data.vertices:
print(i.co, i.select)

With the check in place, that might look something like this:

import bpy
# places us into object mode even if we are already. I prefer this method over
# Toggle() toggle can get messy fast.
bpy.ops.object.mode_set(mode='OBJECT')

# need to be in object mode to do this operation
for i in bpy.context.active_object.data.vertices:
print(i.co, i.select)