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

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

ListOfVectors = readCoords("/Volumes/Stuff/3d/Lorenz/3d-data.txt")

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.

  • $\begingroup$ 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 $\endgroup$
    – sambler
    Dec 31 '13 at 6:38
  • $\begingroup$ This might give some some pointers youtube.com/watch?v=CkbC787SvGk $\endgroup$
    – stacker
    Dec 31 '13 at 15:34
  • $\begingroup$ @sambler Thanks for the reply. I’m not sure if it’s useful, but I’ll think about it. $\endgroup$
    – MetroWind
    Jan 8 '14 at 3:37
  • $\begingroup$ @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~ $\endgroup$
    – MetroWind
    Jan 8 '14 at 3:39

I had this exact same problem a couple of months ago. The solution irc provided to me was to create a full curve and animate the End Bevel Factor. End Bevel Factor on the properties of the curve data

The beginning of your curve is bevel_factor=0. The end of your curve is 1.0. I am pretty sure it maps from the bevel factor to the index of a control point. So if your curve has 11 points (0..10), then bevel 0.3 will include control points (0..3) .

Consider carefully if you want to animate it with a linear animation curve or the default bezier curve.

  • 1
    $\begingroup$ Is there any function that allows me to calculate the end point of the bevel from this “end bevel factor”? Because I really need that… $\endgroup$
    – MetroWind
    Feb 5 '14 at 23:04
  • $\begingroup$ Wonderful, Never thought to use it because of "Bevel" kinda ambigus $\endgroup$
    – snoob dogg
    Sep 18 '18 at 22:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.