0
$\begingroup$

I try to use a script with animation nodes, so i use the node "Script", this node has a button "New Input", but clicking it don't seem to do anything.

Is it any way i could use a script as an animation node, with some inputs like floating points, integers, strings, or even blender object?

$\endgroup$
2
  • $\begingroup$ To me, clicking on this button adds an input. But before it appears, you have to choose the data type in the little window that appears after click on the button $\endgroup$
    – lemon
    Commented Apr 11, 2017 at 14:21
  • $\begingroup$ then how to use this input in the script? (and for outputs) $\endgroup$ Commented Apr 11, 2017 at 22:02

1 Answer 1

1
$\begingroup$

Script node works the same way the other subprograms work in Animation Nodes:

  • Define a subprogram
  • Then invoke it from another part of the node tree

Let say we have:

  • a simple text block with some code in it. Here it calculates a string from a list of objects
  • a group of objects composed here by a cube, a plane, a circle (objects are grouped using CtrlG)

And we want to use the text value of the script to be the text displayed by the text object on the right:

enter image description here

Here in this script 'text' (a string or a text type in AN) will be the result and 'objects' (a list of objects) will be the input.

You can do the following:

  • Add an object group node. Set it to the objects group's name
  • Add a text object output node. Set it to the text object.

enter image description here

  • Add a subprogram as script.
  • Set its input and choose "object list" as type. Eventually rename the input variable value (here we need to rename it to 'objects').
  • Set its output and choose "text". Rename it if needed (here we want it to be named 'text').

enter image description here

  • Add the invoke subprogram node which corresponds to our subprogram's name ("my script" here but you can rename it) and connect input and output of this node.

enter image description here

$\endgroup$

You must log in to answer this question.

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