3
$\begingroup$

thank you for reading my question. I would like to animate a text object in a blender file replacing the body text every 10 frames, iterating row by row through data drawn from a large csv file. There are 2 million rows. The csv data is structured in the following way:

nonce,cost,target,result
1,400,3.12,4
2,400,3.12,3.24
3,400,3.12,1.08
4,400,6.24,3.36
5,400,9.36,33.67

Image shows a screenshot from a blender file which contains the text objects that will be animated By way of an example (using the first 3 rows of my data) I have made this looping animated gif which illustrates in a basic form what I'm trying to achieve. Text that is green/red colour will be replaced every 10 frames with text from the next row in my csv file.

animated gif shows a text object being updated with text data, from the first 3 rows, every 10 frames, drawn from a csv file containing 2 million rows of data.

From my readings here Python seems to be the best way to achieve my animated end goal. There are many excellent answers relating to the use of Python and importing csv data to set the x,y,z location of a mesh or drive a rotation of objects or vertices. Some answers deal with a small amount of changing text data. I cant find an example of how to approach this with text data from such a large data file.

It's entirely possible the solution is obtainable from merging a few answers here, but my python knowledge is not at a level that allows me to make the connections between the expert knowledge given in previous answers.

I'm embarrassed to admit the amount of time I have spent trying to achieve, what seems to be a relatively simple animation. My failure to find a solution has knocked my confidence a little, any guidance is very much appreciated, thank you. I can supply the blend file from my gif animation and a sample of the csv text data if that helps. Thank you very much for your time.

$\endgroup$
4
  • $\begingroup$ sure you want to do it in Blender..? I think it would be like a 200 hours long video, that's more than a week... maybe you want to render just a section of it, or you need something that plays in realtime..? just curious $\endgroup$
    – alambre
    Commented Mar 29, 2022 at 0:34
  • $\begingroup$ And I wonder why you think python is the best option? I would use animation nodes for such a simple task $\endgroup$
    – Chris
    Commented Mar 29, 2022 at 4:01
  • $\begingroup$ @alambre lol you are right about that. I plan to adjust the timing down to every 2 frames for 80% of the data. I didnt want to over complicate the question above. The target for the video material need see that every piece of data is there, and be able to check the sequence of events are in the correct order, but they will mostly skip to parts of particular interest. $\endgroup$ Commented Mar 29, 2022 at 4:05
  • $\begingroup$ @Chris thanks, I'm open to any solution. I may be wrong but any solution I looked at with animation nodes involved adding a python script. I did read one post here where someone had tried something similar with animation nodes but eventually gave up and wrote a python script instead. But I'd be happy to try animation nodes if you think its a good way to approach this. $\endgroup$ Commented Mar 29, 2022 at 4:15

1 Answer 1

3
$\begingroup$

in python you would need to use a handler that updates on frame change, and every n frames read from file and update text object bodies... it's not that complex but 2M lines are a lot of lines to read... here's an answer with nice example of using a handler to update a text object

animation nodes is a great option as Chris stated, I think it can read from text file... but also you can use a little script to import your data as vertices, then even using a handler should be easier and things a lot more stable, as all values are now stored in blend as xyz coordinates -I think first value in your csv was just an index-

here's the script to load data, and a geometry nodes setup you can test, from the imported pointcloud it reads each vertex and writes index and coordinates to text every 10 frames, it's just an example to modify...

blend file

geonodes setup

$\endgroup$
14
  • $\begingroup$ Thanks very much Alambre, I will give this a shot. The first column does look like an index but it's used in part to generate a pseudo random result, the seed is changed at various points in the data and the nonce then resets to 0. Maybe I should break the data up by seed. I think the first seed ran to just half million rows. I wonder how blender will handle big data projects and infinite data streams. $\endgroup$ Commented Mar 29, 2022 at 4:54
  • $\begingroup$ ok then just coordinates may not be enough... just added a second script to blend to generate some fake data, then tried loading a 2 million rows file with no problem... fixed index offset too... about seeds, that could be a simple list of values, no need to store into vertices $\endgroup$
    – alambre
    Commented Mar 29, 2022 at 5:17
  • $\begingroup$ @alambre: very nice! +1 for providing a great solution with blend file and even providing building the csv file! $\endgroup$
    – Chris
    Commented Mar 29, 2022 at 5:42
  • $\begingroup$ @alambre thanks very much for your help, particularly leaving me with enough room to tinker and discover. $\endgroup$ Commented Mar 29, 2022 at 7:19
  • 1
    $\begingroup$ Ask a new question how to do it with animation nodes and I will show you $\endgroup$
    – Chris
    Commented Apr 2, 2022 at 2:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .