I'm stuck with the 'For Loop' part of my project in Animation Nodes.

I'm trying to create a bar chart with each of x bars scaled to a high set by some CSV data. I've got my .blend and it feels so close but I can't make it work.

You'll see that I've created a cube and used the Object Instancer and a loop to create an array of x columns. By putting the pivot point at the bottom of the cube I can scale on z axis give me the height of the bar chart. This node tree ends with the scale attribute in the Object Attribute Output.

Below that node tree I have a Text Block Reader that splits the text (by lines) and then another split (by separator) to get my list which I hoped to use to drive the heights of the columns. This is a string so I've used a node to convert to a float.

Now I'm way out my depth and I can't get the values from the list to drive the different heights of the bars.

Lastly, a nice to have only - If you do have a solution, is there a way to mix between 0 values for Z scale and the values from the CSV list so that I can key frame both and animate the bar chart rising? That would be perfection.

Just a note that I've been able to get to a solution before by using the Python on Tamir Lousky's Github page but wanted to do it in Animation Nodes.

Many thanks to anyone who can help - this is beyond me but I'm trying to learn.

Blend file: https://www.dropbox.com/s/hedqgdwqkh6evrf/animation_nodes3.blend?dl=0

Image of node tree: https://www.dropbox.com/s/kivegj9bm956rps/Nodetree.PNG?dl=0


1 Answer 1


At the moment your “parse” loop loops over the list of lines given by the Split Text node with mode set to lines. This is useful if your .csv file is in this form:

name, value
A, 1
B, 2
C, 3

But if your file is in the form of

A, B, C
1, 2, 3

then you'll have to

  1. split the file into lines,
  2. pick the line with the values in it,
  3. split this line at the value separators outside of the loop
  4. and then loop over the value strings.

subtree for separating lines

Depending on the number format of your values (e.g. decimal comma, thousands separator) you might have to use a script node to parse them. However, a simple Parse Number node might be enough for your file. The parsed number has to be piped into the loop's output that you can generate by clicking New Generator Output and choosing the type Float List.

parse number loop

Finally, the parsed list of numbers will be piped as an additional iterator into the other loop which is used to place and scale the bars (New Iterator > Float List). Using a Vector from Value node, piped into the Object Transforms Ouput is sufficient if you only enable scaling for the Z value, but you could also use a Combine Vector node:

object loop

If the number of columns in your .csv file is the same as the number of bars then you could also combine them into a single loop with one Object List iterator and one String List iterator. However, two loops offer more flexibility if the .csv file should contain a column header (or line header in your case) or when you want to select for which values you want to create a bar.

combined into single loop

  • $\begingroup$ Solution verified. Renaming my loops helped get this straight in my mind and I also found the 'convert' node to change a text list into a float list. $\endgroup$ Apr 17, 2017 at 17:12

You must log in to answer this question.

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