# Get the selected median point in python?

During edit mode, how do I get the coordinates of the median pivot point (position of the transform manipulator) using python?

This information is shown in the Transform panel of the properties sidebar in the 3d view.

• Shift+s->'Cursor To Selected', this will move the 3D cursor to the Objects Origin. Enter Edit Mode and now you can use Shift+s->'Selection To Cursor(Offset)' to move anything to that point. – MarcClintDion Feb 20 '15 at 8:20

You can calculate it quite easy:

import bpy
from mathutils import Vector

ob = bpy.context.object
ob.update_from_editmode()

me = ob.data
verts_sel = [v.co for v in me.vertices if v.select]

pivot = sum(verts_sel, Vector()) / len(verts_sel)

print("Local:", pivot)
print("Global:", ob.matrix_world * pivot)


You could also use the bmesh module, but the standard API appears to be faster despite the update operation:

import bpy
import bmesh
from mathutils import Vector

ob = bpy.context.object
me = ob.data

bm = bmesh.from_edit_mesh(me)
verts_sel = [v.co for v in bm.verts if v.select]

pivot = sum(verts_sel, Vector()) / len(verts_sel)

print("Local:", pivot)
print("Global:", ob.matrix_world * pivot)