Structure node
Get by Index
Retrieves a single element from a structure by its position. Get by Index works on indexed arrays, on named dictionaries (by sorted key position), and even on a single point or vector (by component), with Python-style negative indexing to count from the end. Its Valid output makes out-of-range access explicit, so graphs can react to missing data instead of silently misbehaving.
Inputs
| Port | Type | Default |
|---|---|---|
| StructureThe list to pick from. A named structure works too, read in alphabetical key order, as does a point or color read as x, y, z, w. | structure | — |
| IndexWhich element to fetch, counting from 0. Negative values count back from the end, so -1 is the last; anything out of range gives 0 and turns Valid off. | int | 0 |
Outputs
| Port | Type |
|---|---|
| Element | any |
| Valid | bool |
How It Works
Each frame the node reads the connected Structure and resolves the Index against it, choosing one of three lookup strategies depending on what actually arrives:
| Input kind | Lookup |
|---|---|
| Array (any element type) | Direct positional access: index N returns the Nth element |
| Dictionary (named structure) | Keys are sorted alphabetically and the index selects the value at that sorted position |
| SIMD vector (a single point, color-as-vector, etc.) | Indexes into the components [x, y, z(, w)] — so index 0 is x, 1 is y, 2 is z |
The vector case is what makes point-cloud plumbing seamless: a point extracted from a [SIMD3 cloud is itself a structure, so a second Get by Index opens it into its x/y/z floats.
Negative indices count from the end: −1 is the last element, −2 the second-to-last, and so on — formally, a negative index resolves to length + index. The resolution table for a 5-element structure:
| Index | Result |
|---|---|
| 0 | first element |
| 4 | last element |
| −1 | last element |
| −5 | first element |
| 5 | out of range |
| −6 | out of range |
Out-of-range and fallback behavior. When the resolved index falls outside the structure — or the input is not a structure at all (unconnected, or a scalar) — the node returns Element = 0.0 (a Float zero, not "no value") with Valid = false. Downstream float consumers therefore see a safe zero rather than stale data, and the Valid flag is the reliable signal that the lookup actually succeeded. The Index input is an Int port, but a connected Float is accepted and truncated toward zero.
The Element output is typed Any, so it carries whatever the structure holds — floats, strings, colors, nested structures, points — and its effective type follows the data.
Parameters in Depth
- Structure (structure) — the container to read from: the output of Make Structure, an Array node chain, a point cloud from any Points node, a Break-style structure, a dictionary, or a single SIMD point/vector. Nothing (or a non-structure value) yields Element = 0, Valid = false.
- Index (int, default 0) — the position to fetch. 0-based from the front; negative values index from the back (−1 = last). Floats fed into this port are truncated toward zero (1.9 → 1, −1.9 → −1); if you want proper rounding or floor semantics when driving it from a float source, convert deliberately via a Reroute's Rounding Mode. Out-of-range values do not clamp or wrap — they simply produce an invalid result, which makes accidental overruns visible.
The two ports interact simply: Index is re-resolved against the current Structure every frame, so if the structure grows or shrinks (live arrays, fluctuating point clouds), the same index may alternate between valid and invalid — watch Valid when the source's length is dynamic.
Use Cases
- Pick one landmark: Vision Tracking → Landmarks to Points → Get by Index (slot of the right wrist) → a second Get by Index (0 and 1) to split the point into x and y for driving a Canvas position.
- Step through data on a beat: Counter (advanced by Audio Analysis or Pitch Detection pulses) → Index, walking through a Make Structure list of preset values one hit at a time.
- First and last of a trail: two Get by Index nodes with Index 0 and −1 on a Point Trail output — the head and tail of the trail, e.g. as Rope endpoints.
- Nth entry of parsed JSON: JSON Parse → JSON Break → Get by Index to grab a positional entry from incoming OSC Receiver or TCP data, with Valid gating a Switch so malformed packets fall back to defaults.
- Split a color or vector: any SIMD-valued structure element → Get by Index 0/1/2 to peel individual channels into float math.
- Defensive fallback chain: Valid → Switch selector, choosing between Element and a Constant fallback so a shrinking live array never feeds stale or zero values into a critical render parameter.
Tips
- Element outputs 0.0 (not nothing) on failure — never use "Element is zero" as a presence test, because zero is also a perfectly legal stored value. Valid is the only trustworthy signal.
- Dictionary access is by alphabetically sorted key position, which is stable but not insertion order; when you know the key, Get By Name is the more direct and self-documenting tool.
- −1 is the idiomatic "last element" and keeps working as the structure grows — great for reading the newest entry of an accumulating array.
- Driving Index from float sources goes through truncation toward zero; an LFO scaled across N elements will spend uneven time on the edges. A Reroute set to Floor (or Math with explicit floor) gives predictable stepping.
- For slices, sums, lengths, and other whole-array operations, reach for the Array family (Array Get, Array Slice, Array Length…) — Get by Index is the single-element scalpel.
- Chaining two Get by Index nodes is the standard pattern to go from "cloud of points" to "one coordinate of one point".
Open Get by Index in the interactive catalog →
Get by Index is one of 381 nodes in Grafit Pro.
Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.