Builtin Library
README.md
field.index
The element number, counted from 0. Unwired it is an Int field over whatever reads it (fieldc.leaves.elementId: the number of the element being written). With a domain it is an Int column of 0 to n - 1, one per element of the domain.
Inputs
domain(Any, optional). Whose elements are numbered: a Geometry class (geometry.point), a Column, or a number of elements. Left unwired, the answer is a field over whatever it is read in.
Outputs
field: an Int field (unwired) or an Int column of the domain's length.
Example
local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.index() * 2 })
v holds 0, 2, 4, 6. g.field.index({ domain = points.point }) is the column 0, 1, 2, 3.