Export curve as a list of points

Hello,

I want to export a path as a list of points, preferably with equal distance. But I can’t find how to get the coordinates on a certain curve on a certain position. Is there a function for that?
I thought of some workarounds like:
-Convert the path to a mesh and export every vertex. This won’t give an equal distance between points.
-Let an empty follow the path, bake the animation and export it’s position for every frame. This works but it’s kinda clunky.

What would you suggest?

There is a utility function to evaluate beziers:

from mathutils.geometry import interpolate_bezier

I’m not sure if it works properly for 3D, and how to use it, 'cause it requires two knots and two handles, but every bezier point has two handles…

There is no .evalute() like for FCurves unfortunately, so your idea to let an empty move around sounds pretty good.

Perhaps this helps:


import bpy  
from mathutils import Vector  
import math



def ReadCurveControls():
  for obj in bpy.context.selected_objects:
    print ("# " + obj.name)
    print (' [')
    for spline in obj.data.splines:
      for point in spline.bezier_points:
        angle_right = math.degrees(Vector((1,0,0)).angle((point.handle_right - point.co)))
        if (Vector((1,0,0)).cross((point.handle_right - point.co)).z < 0):
          angle_right = 360-angle_right
        angle_left = math.degrees(Vector((1,0,0)).angle((point.handle_left - point.co)))
        if (Vector((1,0,0)).cross((point.handle_left - point.co)).z < 0):
          angle_left = 360-angle_left
        print ("  [Vector((",round(point.co.x,4),",",round(point.co.y,4),",",round(point.co.z,4),")),",
                round(angle_left,2),",", 
                round(angle_right,2),",", 
                round((point.co - point.handle_left).length, 4),",",
                round((point.co - point.handle_right).length, 4),",",
                "'"+str(point.handle_left_type)+"',",
                "'"+str(point.handle_right_type)+"'],")
    print (']')
    
ReadCurveControls()


Sorry for the late response…

@kakts
The code seems to print the position of points and vectors of the handles of a bezier curve. But that still doesn’t give coordinates on the path. It does give me insight to where curve data is stored, but I think I will just export animation data instead of path data, like CoDEmanX recommends.

Thanks for the help.