# Animation by adding points to a curve, with Python?

I’m trying to make an animation by growing a curve. I have a python script like this, which is based on http://blenderscripting.blogspot.fr/2011/05/blender-25-python-bezier-from-list-of.html

import bpy
from mathutils import Vector

w = 1 # weight
Scale = 0.03

with open(filename, 'r') as File:
Coords = [[float(x) * Scale for x in line.split()] for line in File]
return list(map(Vector, Coords))

def makePolyLine(objname, curvename, cList):
curvedata = bpy.data.curves.new(name=curvename, type='CURVE')
curvedata.dimensions = '3D'

objectdata = bpy.data.objects.new(objname, curvedata)
objectdata.location = (0,0,0) #object origin

polyline = curvedata.splines.new('NURBS')

for i in range(len(cList)):
# bpy.context.scene.frame_set(i+1)
if i > 0:
x, y, z = cList[i]
polyline.points[i].co = (x, y, z, w)

makePolyLine("NameOfMyCurveObject", "NameOfMyCurve", ListOfVectors)


Basically I read the coordinates of points from a file, and add them to a curve in sequence. My question is, how can I animate this process (eg. add 1 point per frame)? I notice there’s a build modifier, but I want precise control on this, so that I know the exact coordinate of the end of the curve at each frame.

• I'm not sure you can animate adding points but you could create a curve with len(cList) points all at the same location then animate moving them into place. You would have to create a hook for each point and keyframe the movement of each hook. see wiki page on hooks Dec 31 '13 at 6:38
• This might give some some pointers youtube.com/watch?v=CkbC787SvGk Dec 31 '13 at 15:34
• @sambler Thanks for the reply. I’m not sure if it’s useful, but I’ll think about it. Jan 8 '14 at 3:37
• @stacker It looks interesting. The problem is though the same with using a build mod. I don’t have precise control, i.e. I don’t know how the movement of the control object is mapped to the curve length. But thanks for the link~ Jan 8 '14 at 3:39