0
$\begingroup$

I have a set of say 20 data points whose x and y coordinates are available in a csv file at each frame . I have 1000 sets of this data with each set describing the location of 20 data points at a given instant (say frame).So essentially i have information about how these 20 points move about in 1000 frames . How to animate the movements of this points as a function of time in blender from the csv file.

Other Questions on the site have described how to read csv files using python etc but none seem to describe an approach to a complete solution for a problem of this kind.

Note : I don't want to interpolate these points to get a mesh .I just want to observe how these points move about with time as mentioned in the file.

An example of the set of columns in csv file: Point ID , X ,Y , time ,color

It would also be nice if you could tell me how to represent these points by circles centered around the respective x and y .

A sample file for illustraion: The following file contains a sample of data but in the form of a spreadsheet instead of csv.The time is in units of seconds http://jmp.sh/v/JfC1Qdh0RTZ85kKzR3lS

$\endgroup$
1
$\begingroup$

I'm going to recommend that each point be represented by a circular mesh (You can create a prototype pretty easily using the Add/Mesh/Circle menu entry). You will then add keyframes for the location data.

There are other answers about importing CSV data:

Here's the excerpt about keyframing position:

def keyframe_location(obj, fname):
    with open(fname, 'r') as loc_fh:
        r_loc = csv.reader(loc_fh, delimiter=',')
        i = 0
        for row_loc in r_loc:
            row_loc = [ float(x.strip()) for x in row_loc[:3]]
            fr = 10+2*i
            obj.location = row_loc
            obj.keyframe_insert(data_path="location", frame=fr)

            i = i+1

You will likely want to instantiate the graphical objects representing the data points using techniques similar to http://www.purplefrog.com/~thoth/blender/python-cookbook/link-mesh-array.html

import bpy

def army(mesh):
    scn = bpy.context.scene
    for r in range(10):
        for c in range(4):
            obj = bpy.data.objects.new("army", mesh)
            obj.location = ( r*3, c*3, 2)
            scn.objects.link(obj)

army(bpy.data.meshes["Cube"])

Any complete solution is going to integrate answers to about 10 distinct questions.

$\endgroup$

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.