I am trying to write a addon which uses Animation nodes addon. I am able to create different nodes such as Object instance, combine vector, math, transform output, loop and invoke subprogram nodes.

I can able to connect to all nodes except object instance node to subprogram node. Getting exception saying that out of index for invokesubprogramnode.inputs[0].

I found in one of the templates before linking updateSocketifnecessary() is called but i am not able access that function from my addon. I need assistance with this.


I still plan to make it easier for other addons to use AN so anything I say here might change in the future, not very soon though.

Before you can create the sockets in the Invoke Subprogram node you need to do three things:

  1. Create the subprogram itself (loop, group, script)

  2. Tell the Invoke Subprogram node which subprogram it has to invoke:

    invokeSubprogramNode.subprogramIdentifier = loopInputNode.identifier

    Every node has an unique identifier (some random string) and every subprogram has an identifier. The identifier of a subprogram is the identifier of its 'owner' node. 'Owner' nodes are: Loop Input, Group Input, Script. Every subprogram has to have exactly one of those.

  3. Update the sockets sockets in the Invoke Subprogram node by calling this function: https://github.com/JacquesLucke/animation_nodes/blob/master/nodes/system/subprogram_sockets.py#L12


Alternatively you can also integrate your code into a Template, which is a special class that makes it easier to create node groups programatically.

Here is an example of a template: https://github.com/JacquesLucke/animation_nodes/blob/master/templates/arrange/distribute_instances_on_spline.py

Even if you don't want to subclass a class of AN you can see how the nodes are created there.

  • $\begingroup$ Thanks a lot, that actually saved me. You addon is simply superb of course I did not tried as I am not full time 3D artist but my interest in 3D world makes me to spend little time in it. I am full time software developer in c#. $\endgroup$ – Patan Amrulla Khan Apr 20 '16 at 5:48

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.