Animation Nodes

I’m trying to calculate the Fibonacci series using AN. I start off with a list containing the numbers 0 to 9. I then create a loop (from 2 to 9) that sets the element at that position to the sum of the 2 previous elements. Unfortunately, it only seems to affect the final element (index 9) in my list. Why is that? What am I doing wrong? TIA!

to my knowledge you should define the list to add the list values as parameter.
In advanced node settings just add a reassign node to the parameter. (Just click reasign and the reassign node ist hooked to your cursor, ready to be placed in the node tree.) This makes the values persistent and the operation values can be used in the next loop cycle.

Thank you for your answer, but I’m not sure I understand what you mean. I do understand that, just like in Python itself, a Range is not necessarily the same as a List. Ie, you can’t change the values of a Range unless you convert it to a List first, which is what I presume you’re saying what I should do. However, I can’t seem to find this ‘Reassign’ you are talking about in the Advanced Node Settings. If I select my Range node, it says ‘Has no advanced settings’.

I could use an Integer List node, but then I’d have to set a fixed number of elements, and I don’t want that. The length of the series should be adjustable.

I’ve attached my blend file, so you could have a look at what’s going on if you want. I’m using Blender 2.79b, with AN 2.0.4. Thanks again!

an-004.blend (434.3 KB)

Well I will take a look at your blend file later on and send a screenshot of the advanced node settings of the loop node, where you define the parameters.

1 Like

Thanks for sending the blend file. I took a look and tried to find out what’s happening, so I added a loop viewer and it looks as if your nodetree does what it shold but you don’t see it by using the “regular” viewer. The loop viewer shows this:

So some calculations are done during the itterations, but they seem to be overwritten.

I didn’t get it working with the reassign, but here is how to activate it. Its a property of the loop input node parameter. I added an integer list. By clicking the reassign butten you get an output node you can feed in the value that is available again at the input node.

Hope this could help a bit.

1 Like

Thank you for taking the time to have a look at this; I very much appreciate it. It’s getting a little clearer, but I’m still not sure exactly how that reassignment works. There seem to be some examples of it in the manual, so I’ll need to look at those more closely, and maybe experiment a little with this node.

BTW, what we see in the loop viewer is what we would see if, every time you get an element from the range, it resets that value to the generated value. So maybe it recalculates the range every time you try to get a value from it? Not sure if this makes any sense, though; just thinking out loud.

Anyway, thanks again for your time and elaboration. If I ever get this to work properly, I’ll be sure to post back here! :slight_smile:

I’m not too familliar with Fibonacci Sequences but I wanted to have a proof of concept.
Here is my approach. Just set the iterations to the desired length of the sequence.

1 Like

Great, this is exactly what I was looking for, thank you! I’ve attached my blend file in case anybody wants to play around with it. fib-001.blend (531.5 KB)

The Fibonacci numbers form a sequence, where the number at position i equals the sum of the previous 2 numbers in the series, so F(i) = F(i-2) + F(i-1), for i > 1, and where F(0) = 0 and F(1) = 1. It has a strong geometrical interpretation, relating to (among other things) the golden ratio: F(i)/F(i-1) approaches the golden ratio as i goes to infinity. This is also illustrated in my blend file. You can read more about it on wikipedia: Not for the mathematically faint at heart, I might add… :wink:

I would also add that there is a simple formula to get the nth element in a fibonachi sequence, without the need to iterate over the previous elements.
It might be easier to use it than the regular way.

That’s very true, and it even uses the golden ration and everything – so how nice is that! :slight_smile:

Using that formula would kinda defeat the purpose of this exercise, though. And while it may possibly be quicker to calculate the n-th number in the sequence this way, I usually need the entire sequence (-up-to-n), which can probably be calculated faster the ‘classic’ way. Maybe that’s just me, though; your mileage probably varies on what you actually want to do with those numbers. :wink:

Hi, I’m a complete AN noob. I’ve been using blender for years, but i’m pretty clueless when it comes to this awesome plugin, even though I know how to compile it… xD

I have a project i’m doing where i’m supposed to show a robot being guided by a 3D camera. There is a camera that is set up on the side of a production line. I’m going to make a loop where an object passes through the pointcloud. I need the points to have slight animation, so it kinda ‘lives’ a little. And then these points need to be displaced by the object being animated through it… I don’t even know where to start with this. Particles, instanced objects on a plane, I have absolutly no idea which one would be the best, or even how to do it… I know people here have things to do, but if there is someone here that can help me, I would be very happy. :slight_smile: Right now I’m doing an emergency-solution with a polkadot pattern on a shrinkwrapped plane that kinda follows the object. But it doesn’t really look optimal, and my customer is really picky… xD


How can I get a None object? For example, in a loop, I would like to add something to a list only when certain conditions are met. Here’s what it would look like:
In the above example, I’d like to append something to the list only if the condition is False. If the object connected to the ‘True’ input were None, I’d expect nothing would be added to the list. How can I do this? TIA!

PS: I’ve tried not connecting that input, but that doesn’t work. Also note that the list in question is defined as an ‘Integer List’ parameter of a Loop. The ‘A’ input of the condition is the Index of that Loop.

Here’s my blend file: recaman-002.blend (665.8 KB)

That should be possible with AN.

I wondered why your approach doesn’t work.

The point seems to be a matter of datatypes and lists. I did’t get None values added to an integer list.

So I tried a generic list and it works without a data type mismatch error. Hope this could help.

1 Like

Thanks, and while that does clear up certain issues I was having, it doesn’t really solve my problem, I think, so let me rephrase that using an example:

I would like a network that, given a list of numbers (int/long), filters out those numbers that are divisible by 3. So given the input list [1, 3, 4, 5, 7, 33], I would like to generate this output list: [3, 33]. How can I best do this?

If I were to program this in Python, I’d iterate over all the numbers in the input list, and add the current number to the output list if it is divisible by 3. So it comes down to being able to decide whether or not to perform a certain action (append element to list) depending on certain conditions (number is divisible by 3).

What I tried was, when the conditions are not met, set the output list to be added to to None, so no element could possibly be added. But I can’t get that to work.

Actually, see that button in the bottom right corner? I’d like there to be an extra button, saying ‘New Continue Condition’.

Well I focused on the None values assuming they were needed for further processing.

Well the condition input you’re looking for exists but its a little hidden.

The reassign loop parameter has a “Condition” input that is hidden by default. If you activate it it is accessible in the node tree.

Another point to keep in mind ist to activate the “Copy” option of the reassign list parameter.

So I assume this node tree works as you want it to. I tested it with some random numbers that I convert to Integer (floor) (becaus meeting the condition with floats is very unlikely).

To get into details you can look them up in the AN documentation.


Just the other day I was rigging and thought, gee, I could make myself a nice 3d blendspace for that hip joint with animation nodes. Was quite disappointed to see no bone support.

Is there any word on when we might see some bone-related nodes in AN?

Yep, that sure solves the problem I was having. Thanks for your time and effort to help me get this to work!

I still haven’t quite gotten my head around this reassignment business, it seems. I’ve been reading most of the documentation where this is mentioned, but I can’t seem to grasp the rationale behind this. Why is this necessary? Why does this reassignment not happen by default? Is there an equivalent in ‘regular’ programming? If somebody could point me towards an answer to these questions, that would really help me out in my future endeavours. I wouldn’t want to have to keep bothering everybody here whenever I’m writing a new loop, right… :wink: