Accessing the foliage container array in blueprints

I am looking at creating a dynamic foliage replacement system a kin to the one shown in this tutorial:

But I have found an issue when modifying it to work with additional meshes, when the user adds a foliage to the foliage placement tool it enters as “instance_1” the next as “instance_2” and so on.

This mean I can align my replacement array up with the substring length -1 number and use that as the particular dynamic foliage that I want to swap out to.

The issue arises when an item from the list is removed and a new one inserted, this leads to “instance_3” coming after “instance_1” for example.

anyone know of a way to, via detection in the scene, access the item in the foliage array to get a more useable number rather than using the given name?

I have found a solution, getting all the Foliage instance static mesh components in the instanced foliage actor and adding them to a map (Dictionary) with the key being the name of the foliage and the value being a count that is incremented giving a list of “instance_0 → 0”, “instance_1-> 1”, “instance_3 → 2” etc independent of the order they were added.

Now the collision with the elements of the foliage structed can be found and an appropriate number linked to it.