I placed some bezier curves in a scene. This scene is getting exported as an .obj file later with a scaling factor of 11 and +X-axis as Forward and +Z-Axis as Up. as In a further project some insects shall move along these curves. Now I need the handle and control points of these bezier curves in world coordinates so I can use these coordinates to calculate the bezier curves in my project. I wrote a script for that:
import bpy
import os
ob = bpy.context.object
currPath = os.path.splitext(bpy.data.filepath)[0]+".txt"
file = open(currPath, "w")
for curves in bpy.data.curves:
for splines in curves.splines:
for x in range(len(splines.bezier_points)):
file.write("p ")
handle_left = ob.matrix_world * splines.bezier_points[x].handle_left
handle_left *= 11
co = ob.matrix_world * splines.bezier_points[x].co
co *= 11
handle_right = ob.matrix_world * splines.bezier_points[x].handle_right
handle_right *= 11
file.write("%.3f " % (handle_left.x))
file.write("%.3f " % (handle_left.y))
file.write("%.3f " % (handle_left.z))
file.write("%.3f " % (co.x))
file.write("%.3f " % (co.y))
file.write("%.3f " % (co.z))
file.write("%.3f " % (handle_right.x))
file.write("%.3f " % (handle_right.y))
file.write("%.3f " % (handle_right.z))
file.write("\n")
file.write("n\n")
file.close()
The bezier curves are not at the position where they should be in my project. Is something wrong with the script?
bpy.data.curves
, instead export curves from the active scene, since its possible there are curves which are not visible in the 3D-view being exported. $\endgroup$