Script
Run Python over up to eight numeric inputs and return up to four numeric outputs.
What it does
Runs a small Python function directly in the graph. The code defines an execute(inputs, cx) function that reads named values like in_0 from inputs and returns a dictionary of named outputs like out_0. Input Count and Output Count add or remove numbered ports, up to eight inputs and four outputs.
A new node carries a one-in, one-out passthrough. Shell access for running subprocess commands is off by default and must be switched on deliberately.
When to use it
Custom logic that fits no existing node and is not worth building as a full plugin: maths, branching, string or data wrangling.
A calculation with several numeric inputs and outputs, wired straight from other nodes in the graph.
A call out to an external command-line tool as part of a script step.
| Parameter | Type | Default |
|---|---|---|
code | String | "def execute(inputs, cx): ..." |
input_count | Number | 1 |
output_count | Number | 1 |
allow_shell | Boolean | false |
in_0 | Number | — |
in_1 | Number | — |
in_2 | Number | — |
in_3 | Number | — |
in_4 | Number | — |
in_5 | Number | — |
in_6 | Number | — |
in_7 | Number | — |
Gotchas
An unused input port is not read, and any output key the function does not return falls back to zero. There is no need to fill every port every time.
Shell access is off by default. Switch on Allow Shell only where the script needs to run external commands. Left off, the node executes nothing outside its own Python code.
Raising Input Count or Output Count adds numbered ports (in_0, in_1, …, out_0, out_1, …), but the execute function still has to read and return those exact keys. Adding a port does not wire it into the code.
Worked example
Add a Script node. Leave Input Count and Output Count at 1 to start.
Open the code field and edit the
executefunction, for example multiplyingin_0by two and returning it asout_0.Wire a Number node into
in_0and watchout_0update.For more values in or out, raise Input Count or Output Count and reference the new
in_N/out_Nkeys in the code.Only if the script needs to shell out to another program, switch on Allow Shell.