Convert selected mesh to Grease Pencil object

Just a quick little script I made that converts a selected mesh to GP strokes on a new GP object. Mostly just an update to other older scripts from 2.7 that no longer work. Figured I’d post it here in case anyone else has the same problem and googles the sam

import bpy
from mathutils import Vector

obj = bpy.context.object
mesh =

gpencil ='gpencil')

layer ="alayer", set_active=True)
frame =
stroke =
stroke.line_width = 100
stroke.display_mode = '3DSPACE'
# assign material
stroke.material_index = 0

for edge in mesh.edges:

    #edge.vertices[0] and [1] are indices inside
    points = [
        obj.matrix_world @ mesh.vertices[edge.vertices[0]].co,
        obj.matrix_world @ mesh.vertices[edge.vertices[1]].co,

    for point in points:
        print(point) #should be each point's obj data?
        stroke.points[-1].co.x = point[0]
        stroke.points[-1].co.y = point[1]  
        stroke.points[-1].co.z = point[2]  
obj ='agobject', gpencil)

# create material
mat ='mymaterial')