Get Length of Path

I was trying use the following script for getting the length of a path

import bpy


curveObj =["NurbsPath"] = True = curveObj

# the duplicate is active, apply all transforms to get global coordinates
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)

# convert to mesh
bpy.ops.object.convert(target='MESH', keep_original=False)

curveData =
edge_length = 0
for edge in curveData.edges:
   vert0 = curveData.vertices[edge.vertices[0]].co
   vert1 = curveData.vertices[edge.vertices[1]].co
   edge_length += (vert0-vert1).length

# deal with trailing float smear
edge_length = '{:.6f}'.format(edge_length)

The problem is that curveData has no edges. I tried to copy some work i saw for computing the length of curve. What am i missing?

it’s easy, you have converted the curveObj in mesh so you must choose active the last mesh and not the old curveObj.