Recursion issue

Discussion created by KennethLinformi-dk-esridist Employee on Sep 21, 2016
Latest reply on Oct 11, 2016 by KennethLinformi-dk-esridist

Hi, I’m trying to create a little hobby project. The background for this is that I have a lot of textures, and no order in those. So my idea was to link a texture finder rule into all my other rules, and when necessary activate a plane with all the textures matching my filesearch criteria, and a annotation below that I could use in the main rule to texture my models.

I created  a primitivequad, that will have the sqrt size of the total number of textures in the filesearch. The I’ve splited it up in the x and z direction. That would bring me a grid, where I need to assign different materials to each one.

I redefined the Index of my splits so it will keep growing, so if the last split in the X direction in the first split of the Z direction will end up with Index 10 the first split in the X direction  in the second split of the Z direction will be 11, and so on….

Okay… I can do a listItem on a string from a fileSearch, so let’s say the I have a spit with a value of 10, I would like the the 10th texture in the listItem, comeing from the fileSearch to be assigned to that Index.

No problem there, if I create a case for each Index, but I need that to be a recursion, and now the chain is broken.

I think I’ve tried to put this together in every different ways I could think of, but maybe I’ve stared my self blind on it.

In my rule the Selector is the definition of which number of texture it should take from the list, the Number is the Index.

So in case the number equals the selector map the texture that has the same index/Selector value as the number.

Else go back to the same rule and raise the Selector value with one, until there is no more splits == Selecto > ListSize : NIL

Maybe this is cryptic writing , but hopefully it makes sense:  


PS: I know that the current recursion will not work 


attr ListSize = listSize(fileSearch("Textures/*"))
attr ListSearch = fileSearch("Textures/*")
Start -->
primitiveQuad(ceil(sqrt(ListSize)), ceil(sqrt(ListSize)))

SplitX -->
split(x) {1 : SplitY(split.index)}*

SplitY(IndexOne) -->
split(z) {1 : Shape(IndexOne,split.index+1,,1,1)}*

Shape(IndexOne,IndexTwo,Total,Iterations,Selector) -->

Next(Number,Selector) -->
case Number > 1000 : NIL
else : set(material.colormap,listItem(ListSearch,Number))projectUV(0) Next(Number,Selector+1)