Hi @Yves ,
I didn’t understand what you are asking exactly but I will try to answer,
you can create a collection variable, a collection stores multiple values of the same type (Layer/Item/Number/Text and more) as a list, you first need to add values items to the collection and then you can loop through the items in the collection and repeat the same actions on all the values in the collection like you do with a simple loop.
I created an example for an automation the that creates a collection of all the words in a text variable and then loop through the items and create text layer for every item in the collection, so basically this automation creates a text layer for every word in a sentence.
Collection Example.json (7.5 KB)
the process of adding items to a collection is quite simple, there is an action for adding one item to the collection and in some cases there are multiple actions that can add many items automatically…
for example in this case I used the collection action “add words as elements”, this action split the text based on the empty spaces between the characters and adds each word to the collection, I could also use the “add element” action and manually add each item to the collection separately.
looping through the items is a bit unintuitive, most loops gives you automatically each layer as the value of the loop, so if you loop over the “layers in the active comp”, “loop1” will represent each layer.
looping on a collection won’t work like this, you will have to set up the loop yourself, but it’s not that complicated(3 lines), you need to use the loop “custom amount of times” option and use the “collection length” property of the collection, this will set the number of times the loop will run to the number if elements in the collection so if the collection contain 4 elements the loop will run 4 times (but the value of the loop will be the number of the cycle 1,2,3,4 so “loop1” won’t represent a collection element, it will represent just an index - number),
then you needs to add 2 more lines within the loop to set the index of the collection, the index will determine the current item you want to look at, the index won’t be changed automatically based on the loop index, so if you won’t set it to the loop index it will stay on the first item and run the loop multiple times with the first item in the collection.
then you will need to create a variable for the item itself to access it’s properties and actions, so after you set the index of the collection you needs to set a variable with the collection property “element at index”, it will give you the current item at this index.
that’s a long explanation for just 3 automation lines but hope it answered your question,
please let me know if I didn’t answer your question at all… or you just have more questions.