I would like to create a script to import coordinates from a CSV and create a bezier curve along these coordinates. I have developed a script that imports the coordinates, but it creates a curve along only one coordinate point. All remaining points are ignored and the curve always starts at the coordinate origin (0,0,0). Unfortunately I don't have a good knowledge of Phython. Therefore it would be great if someone could help me. Thanks a lot!
from mathutils import Vector
import bpy
import csv, os, bmesh, math
#filepaths
filepath = bpy.data.filepath
directory = os.path.dirname(filepath)
verts = []
edges = []
faces = []
csvpoints= "NameofFilepath"
pointsReader = csv.reader(open(csvpoints, newline=''), delimiter=';')
bpy.ops.curve.primitive_bezier_curve_add(enter_editmode=True)
with open(csvpoints, 'rt', encoding="utf8") as csvfile:
pointsReader = csv.reader(csvfile, delimiter=';')
for idx, row in enumerate(pointsReader):
if (idx > 0):
vert = (float(row[0]), float(row[1]), float(row[2]))
verts.append(vert)
# Create curve and cache reference.
curve = bpy.context.active_object
bez_points = curve.data.splines[0].bezier_points
bez_points = curve.data.splines[0].bezier_points
# Set handles to desired handle type.
for bez_point in bez_points:
bez_point.handle_left_type = 'FREE'
bez_point.handle_right_type = 'FREE'
# Left point.
bez_points[0].co = vert
[![Coordinates in CSV][1]][1]