How do you store the edge locations of a cube with python? Basically I want to find the edges for the default cube, so I can store their location, then use the locations to draw grease pencil strokes. I have been successful at figuring out how to print out the 12 edges with bmesh, but I don't know how to read the data format that bmesh has created to store the location data.

&lt;BMEdge(0x00000263C41B0BB0), index=3, verts=(0x00000263C155E0B8/3, 0x00000263C155E080/2)&gt;


Here is my simple script below.

import bpy, bmesh

# Store object data
me = bpy.context.object.data

# Create a new empty bmesh object
bm = bmesh.new()
# Use the method from_mesh to fill in the mesh
# with the active mesh.
bm.from_mesh(me)

# Create new grease pencil frame
# gp_layer = init_grease_pencil()
# gp_frame = gp_layer.frames.new(0)

edgeList = []
# Loop edges
for edge in bm.edges:
    print(edge)
    # prints 12 edges in the following format
    # &lt;BMEdge(0x00000263C41B0BB0), index=3, verts=(0x00000263C155E0B8/3, 0x00000263C155E080/2)&gt;

    # Store the edge coordinates here. 
    # E.g edgeList.append([p1, p2]) where p1 and p2 are the corner vertices.

bm.to_mesh(me)
bm.free()

# TODO
# Create new grease pencil stroke.
# Loop edgeList.
# Draw stroke base on the save coordinates.
You are very close

Can create the list in one fell swoop using list comprehension.  (instead of edge_list.append(tuple(v.co for v in e.verts))  Used a tuple for vert coords as we really don't want to add or remove or sort or..

Python console code, notice don't need to print items as their repr is echoed.

&gt;&gt;&gt; edge_list = [tuple(v.co for v in e.verts) for e in bm.edges]
&gt;&gt;&gt; for verts in edge_list:
...     verts
...    


And result on default cube

(Vector((1.0, 0.9999999403953552, -1.0)), Vector((1.0, -1.0, -1.0)))
(Vector((1.0, 0.9999999403953552, -1.0)), Vector((-0.9999996423721313, 1.0000003576278687, -1.0)))
(Vector((1.0, 0.9999999403953552, -1.0)), Vector((1.0000004768371582, 0.999999463558197, 1.0)))
(Vector((1.0, -1.0, -1.0)), Vector((-1.0000001192092896, -0.9999998211860657, -1.0)))
(Vector((1.0, -1.0, -1.0)), Vector((0.9999993443489075, -1.0000005960464478, 1.0)))
(Vector((-1.0000001192092896, -0.9999998211860657, -1.0)), Vector((-0.9999996423721313, 1.0000003576278687, -1.0)))
(Vector((-1.0000001192092896, -0.9999998211860657, -1.0)), Vector((-1.0000003576278687, -0.9999996423721313, 1.0)))
(Vector((-0.9999996423721313, 1.0000003576278687, -1.0)), Vector((-0.9999999403953552, 1.0, 1.0)))
(Vector((1.0000004768371582, 0.999999463558197, 1.0)), Vector((0.9999993443489075, -1.0000005960464478, 1.0)))
(Vector((1.0000004768371582, 0.999999463558197, 1.0)), Vector((-0.9999999403953552, 1.0, 1.0)))
(Vector((0.9999993443489075, -1.0000005960464478, 1.0)), Vector((-1.0000003576278687, -0.9999996423721313, 1.0)))
(Vector((-1.0000003576278687, -0.9999996423721313, 1.0)), Vector((-0.9999999403953552, 1.0, 1.0)))


Notice these are in local coordinates of the mesh. To convert to globals, ob is the object with mesh as data

global_vert_co = ob.matrix_world @ v.co