How to Flatten a vertex path (a list of connected edges) into a straight line while keeping distances?
After long hours, here's an answer to my OWN question, thanks to comments from @Jachym Michal and @batFINGER.
import bpy
import math

def rotatePoint(centerPoint,point,angle):
    &quot;&quot;&quot;Rotates a point around another centerPoint. Angle is in degrees.
    Rotation is counter-clockwise&quot;&quot;&quot;
    temp_point = point[0]-centerPoint[0] , point[1]-centerPoint[1]
    temp_point = ( temp_point[0]*math.cos(angle)-temp_point[1]*math.sin(angle) , temp_point[0]*math.sin(angle)+temp_point[1]*math.cos(angle))
    temp_point = temp_point[0]+centerPoint[0] , temp_point[1]+centerPoint[1]
    return temp_point

def crossProduct(a, b):
    c = [a[1]*b[2] - a[2]*b[1],
         a[2]*b[0] - a[0]*b[2],
         a[0]*b[1] - a[1]*b[0]]

    return c

def dotProduct(a, b):
    c = a[0]*b[0] + a[1]*b[1]+ a[2]*b[2]
    return c

cyl = bpy.context.object
if cyl:
    flt = cyl.copy()
    me = flt.data.copy()
    flt.data = me    
    
assert(len(me.vertices) &gt;= 3)

verts = me.vertices
Nvert = len(me.vertices)
print('Nvert=', Nvert)

nVertRots = 0

for n in range(Nvert - 1, 1, -1):
    print('Vertex:',n)
    v1 = verts[n - 1].co - verts[n - 2].co

    v2 = verts[n].co - verts[n-1].co

    v1mag = math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z)

    v1norm = [v1.x/v1mag , v1.y/v1mag , v1.z/v1mag]


    v2mag = math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z)


    v2norm = [v2.x/v2mag , v2.y/v2mag , v2.z/v2mag]


    res = v1norm[0] * v2norm[0] + v1norm[1] * v2norm[1] + v1norm[2] * v2norm[2]

    angle = math.acos(res)
    
    cross = crossProduct(v1norm, v2norm)
    sign = dotProduct([0,0,1], cross)
    if sign &lt; 0:
        angle = -angle
        
    print('Angle(1,2):', angle)
    
    nVertRots += 1
    for m in range(n, Nvert, +1):
        v2rot = rotatePoint([verts[n - 1].co.x, verts[n - 1].co.y],[verts[m].co.x, verts[m].co.y], -angle)
        verts[m].co = (v2rot[0], v2rot[1], verts[0].co.z)


print('nVertRots:',nVertRots)
if nVertRots &gt; 0:
    bpy.context.collection.objects.link(flt)