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.
<BMEdge(0x00000263C41B0BB0), index=3, verts=(0x00000263C155E0B8/3, 0x00000263C155E080/2)>
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
# <BMEdge(0x00000263C41B0BB0), index=3, verts=(0x00000263C155E0B8/3, 0x00000263C155E080/2)>
# 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.