# How to list vertices coordinates from selected edge

I need to list the extremities of an edge. I've got a selected edge in edit mode and I need to list the coordinates. This will be very useful!

This because I'm looking for the rotation of an edge on the XY plane. I've already figured out how to get the angle but I need the two vertices coordinates to start the math. Hope there is a built-in method!

This will display the coordinates of the selected vertices of the selected object ( you have the local and the world coordinates as @poor have noted )

import bpy

obj = bpy.context.object
bpy.ops.object.mode_set(mode = 'OBJECT')
#all selected vertices indecies
verts_ind = [i.index for i in obj.data.vertices if i.select]
bpy.ops.object.mode_set(mode = 'EDIT')

for i in verts_ind :
local_co = obj.data.vertices[i].co
world_co = obj.matrix_world * local_co
print(world_co)

• You are too fast :) What about obj.matrix_world * obj.data.vertices[i].co?
– p2or
Commented Mar 24, 2015 at 14:37
• Thank you both for the world coordinates. The local_co will also be useful.
– isar
Commented Mar 24, 2015 at 15:17
• with blender 2.8 need to replace * by @ world_co = obj.matrix_world @ local_co Commented May 13, 2020 at 11:17

Bmesh module variant, which does not require a mode change:

import bpy
import bmesh

ob = bpy.context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)

mat = ob.matrix_world

for edge in bm.edges:
if edge.select:
print("Edge {}\n".format(edge.index))
for vert in edge.verts:
print("  Vertex {}:".format(vert.index))
print("    ", vert.co, "local")
print("    ", mat * vert.co, "global\n")
break


Note that above code works in edit-mode only, but it's also possible to extend it with support for object mode.