Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

attribute.labels

An attribute's values as a per-element column, and the index label names among them: what a comparison reads to keep the points of one name. A text attribute's values are each element's index among the texts it holds, counted from 0 in the order the texts first appear; a numeric attribute's are its numbers, which the detail's labels names (how a solver's stream names each particle's source).

Inputs

  • geometry (Geometry). Whose attribute is read.
  • name (String). Default "". The attribute read. A name the class does not carry is refused, naming the ones it does.
  • class (one of point, vertex, primitive). Default "point". Which elements the attribute is on.
  • label (String | Float). Default "". The name (or number) whose index index answers. A text attribute is compared by label, so leaving this empty for one is refused.

How index is found:

  • A text attribute: the place of label among the texts it holds, or -1 when no element holds it.
  • A numeric attribute and a number: the number itself.
  • A numeric attribute and a name: the place of the name in the detail's labels[name] list; a name the list does not hold is refused, naming the list.
  • No label on a numeric attribute: -1.

Outputs

  • values: a column with one value per element: the text's index for a text attribute, the attribute's own numbers for a numeric one.
  • index: the index label names.

Example

local rig = g.elements.entity({ name = "Rig" })
local arm = g.elements.entity({ name = "Arm" })
local both = g.core.concat({ geometries = { rig, arm, rig } })
local labels = g.attribute.labels({ geometry = both, name = "name", label = "Arm" })

labels.values holds 0, 1, 0 and labels.index is 1: the elements whose value equals the index are the arms.