I'm actually trying to export a beziercurve animation in a txt file with this python code :

    import bpy

obj = bpy.context.active_object
matrix = obj.matrix_world

file = open("C:/example.txt","w")
if obj.type == 'CURVE':
   for subcurve in obj.data.splines:
      curvetype = subcurve.type
      print('curve type:', curvetype)
      if curvetype == 'POLY':
            for bezpoint in subcurve.bezier_points:
               loc = matrix * bezpoint.co
               x = loc.x
               y = loc.y
               z = loc.z
               file.write("v " + str(x) + " " + str(y) + " " + str(z) + " " + str(tilt) + "\n")

But when i press run code button, nothing happens in the txt file and I have the curvetype message in the console (curve type : POLY)

My curve type is POLY, I subdivided the bezier 5 times and I succefully created a cube mesh to create the animation (follow path).

Here is an image of blender :enter image description here

Please I really need help :) Thanks.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.