I am looking to retrieve al the starting and ending vertices per edge of an object (standard box in this case). For this I have created the following code:
import bpy
import bmesh
import numpy as np
get a reference to the active object
mesh_obj = bpy.context.active_object
create a new bmesh object
bm = bmesh.new()
initialize the bmesh object using the mesh data
bm.from_mesh(mesh_obj.data)
#Extract all vertex coords and package for export
vertices = np.empty((0,3),int)
for v in bm.verts:
vertex = np.array([v.co.x, v.co.y, v.co.z])
vertices = np.append(vertices,[vertex], axis=0)
edges = np.empty((0,2),int)
for e in bm.edges:
edge = np.array(e.verts)
edges = np.append(edges,[edge], axis=0)
print(vertices)
print(edges)
bm.free
The result however is:
[[ 1. 1. 1.]
[ 1. 1. -1.]
[ 1. -1. 1.]
[ 1. -1. -1.]
[-1. 1. 1.]
[-1. 1. -1.]
[-1. -1. 1.]
[-1. -1. -1.]]
[[<BMVert(0x0000020D001D3D68), index=5>
<BMVert(0x0000020D001D3DD8), index=7>]
[<BMVert(0x0000020D001D3C88), index=1>
<BMVert(0x0000020D001D3D68), index=5>]
[<BMVert(0x0000020D001D3C50), index=0>
<BMVert(0x0000020D001D3C88), index=1>]
[<BMVert(0x0000020D001D3DD8), index=7>
<BMVert(0x0000020D001D3DA0), index=6>]
[<BMVert(0x0000020D001D3CC0), index=2>
<BMVert(0x0000020D001D3CF8), index=3>]
[<BMVert(0x0000020D001D3D30), index=4>
<BMVert(0x0000020D001D3D68), index=5>]
[<BMVert(0x0000020D001D3CC0), index=2>
<BMVert(0x0000020D001D3DA0), index=6>]
[<BMVert(0x0000020D001D3C50), index=0>
<BMVert(0x0000020D001D3CC0), index=2>]
[<BMVert(0x0000020D001D3DD8), index=7>
<BMVert(0x0000020D001D3CF8), index=3>]
[<BMVert(0x0000020D001D3DA0), index=6>
<BMVert(0x0000020D001D3D30), index=4>]
[<BMVert(0x0000020D001D3D30), index=4>
<BMVert(0x0000020D001D3C50), index=0>]
[<BMVert(0x0000020D001D3CF8), index=3>
<BMVert(0x0000020D001D3C88), index=1>]]
The results of the coordinates of the vertices are fine but I just don't see how te get the indices of the vertices belonging to an edge.
Why are the results of the indices not just the index number but {BMVert(@@@@) ?
How can I obtain just the index numbers?