Skip to main content

Context Index


The Context Index Utility acts as an input that only exists during the computation of the Layers. Layers that have an input connection from other Layers may choose to provide context to these input layers to produce different results. The Duplicator is one such Layer providing an index context to all of its inputs.


Check out the Context page for some background reading on this concept.

This utility allows us to use the context information to achieve more specific and intricate results.

To visualise the 'index context', follow these steps:

  1. Create a Text Shape.
  2. Using the + button next to the String attribute, add a String Generator.
  3. Set Generator to Value.
  4. Set Precision and Padding to 0.
  5. Add the Text Shape to a Duplicator.
  6. On the Grid Distribution set the Count to X = 1, Y = 10.
  7. Create a Context Index Utility.
  8. Connect contextIndex.idstringGenerator.number.

The Duplicator includes an Index Context attribute under its Advanced tab. It's possible to skip creating the Context Index Utility and connect directly from the Duplicator instead. e.g. Replace steps 7 and 8 above with:

  1. Connect duplicator.indexContextstringGenerator.number.

Nothing too unexpected there. So let's take this a bit further.

Context Depth

When a layer provides context, it gets added to a chain of contexts. If we have a Duplicator within a Duplicator, then the chain will contain two index contexts. What the Context Index allows you to do is choose the 'depth' of those contexts provided to other layers.

Example (continued from the previous example):

  1. Add the Duplicator to a second Duplicator.

  2. Set Duplicator2's Grid Distribution to Count X = 5, Count Y = 1.

    Result: The index value travels through the second Duplicator.

    An index of 0-49 (50 total) passed to all duplicates.

    Duplicator1 automatically accumulates the index from Duplicator2, which is why we get numbers ranging from 0 to 49 even though we have selected a Depth value of 1. We can change this:

  3. In the Attribute Editor, uncheck Use Index Context under Duplicator1's Advanced tab.

    Result: The numbers now represent the index from Duplicator1.

    A Depth of 1 outputs the index provided by Duplicator1
  4. Set Depth on the Content Index to 2.

    Result: The numbers now represent the index coming from Duplicator2.

    A Depth of 2 outputs the index provided by Duplicator2


Combining Context Index Utilities with a Jsmath Utility can create some interesting results.

  1. Create another Context Index Utility.
  2. Ensure Depth is set to 1 (default).
  3. Create a Jsmath Utility.
  4. Connect contextIndex2.idjsmath.array.0.
  5. Set the Expression to be: 0.5 + n0 * n0 * 0.01.
  6. Connect jsmath.idduplicator1.shapeScale.x.
  7. Connect jsmath.idduplicator1.shapeScale.y.
Using the index of Duplicator1 to scale the shapes generated by Duplicator2.