2
$\begingroup$

I generated a curve using the following python code

curve = bpy.data.curves.new("Curve", type='CURVE')
polyline = curve.splines.new(type='POLY')
polyline.points.add(n - 1) # The polyline has one point when created
polyline.points.foreach_set('co', data) # data is the array of coordinates

This works perfectly in generating the data I want. And now I want to create an animation for this curve by using pre-calculated data stored in a file.

Thus I am trying to use in a different script the following:

curve= bpy.data.objects["Curve"]
# for i ...
    # get new data
    curve.data.splines.foreach_set("location", data)
    curve.keyframe_insert(data_path="location", frame=i)

I tried different variations of the above segment to find a way to get to the points in the splines but no attributes exist for that.

Any suggestions?

$\endgroup$

1 Answer 1

2
$\begingroup$

Apparently the answer is simple to this, I had to choose splines[0]

curve = bpy.data.objects["Curve"]
points = cable.data.splines[0].points
# for i ...
    # get new data
    points.foreach_set("co", data)
    for point in points:
        point.keyframe_insert(data_path="co", frame = i)
$\endgroup$
1
  • $\begingroup$ Cool, I was going to suggest using hooks or shapekeys. $\endgroup$ Commented Feb 14, 2017 at 10:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.