3
$\begingroup$

I need to understand the basic foundations of how the Animation Nodes add-on calculates and executes code.

So there is Auto-Execution, then options like Always, Tree Changed, Frame Changed, Property Changed.

Those options are ok for one node tree. I have not used multiple node trees.

Supposed I have a Script Node that I just need to run once. Jacques told me that I can use the Execute Node Tree button.

Which means... ok, suppose I have a Script node that just needs to do something one time: Perhaps calculating the shortest path distance of 10 vector positions based on a single point and target point.

When the above gets calculated all the time, it will just freeze Blender.

Should I then create a Script node in one node tree and execute it once, and then use the data and store it somewhere (maybe as Text) and then continue?

Another way, maybe I just want Animation Node to check an Object in the scene, and print out the name. One time only. When I use script node, it gets executed all the time.

There is this trigger thing, but I am not too familiar with it. Can we have example?

$\endgroup$

1 Answer 1

7
$\begingroup$

I will try to explain the execution system of AN:

At first there are normal nodes. Each node resembles a specific function. It computates an output based on the input.

Multiple nodes together form a network. All nodes that have the same color belong to the same network (except Invoke Subprogram nodes, these are a bit special to make it easier to see what belongs together).

There are different types of networks. At the highest level I differentiate between main and subprogram networks. By default all subprogram networks are colored and main networks are (light) gray. Furthermore there are different types of subprograms: Group, Loop and Script

Main networks can be executed on their own while subprograms cannot. Subprograms always need to be called from another network. Most of the time they even have additional input which the caller has to provide. To call subprograms we have the "Invoke Subprogram* node.

Multiple networks (both: main and subprograms) together make up a node tree in Blender. It is not important in which node tree the subprograms are because you the Invoke Subprogram node can also invoke subprograms that are in another tree. However, it is important in which node tree your main networks are.

Each node tree can be executed individually. Executing a node tree means to execute all the main networks in it.

Because of that each node tree has separate execution settings. A node tree can either be executed automatically (this is what the Auto Execution panel is for) or you can execute it manually (or both).

So in your case you could put the nodes that should only be executed once in one node tree. And all the others in another node tree. For the first one you can disable Auto Execution and just use the Execute Node Tree button.

I also wrote something about it here: https://blender.stackexchange.com/a/43697/5449

$\endgroup$

You must log in to answer this question.

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