boolean precontition for collect values, odd behavior

2295
3
07-04-2016 02:30 PM
MarceloOyuela
New Contributor III


Hello,

I am using model builder to search rasters containing specific strings in the name within a folder.

cpt3.PNG

What I want is to use the iterator in all raster in a folder, then run the "collect values" only if the precondition is true: "% Name%". find ("45") !=1

It works to some degree, always adds the first raster represented in the folder. In this case I look for the raster with the letters "45", the collect value ignores everything other than "45" except the first thing in this case "prec_1.asc_26.tif". (See the result of the collect value).

With the "recursive" option in the iterator, the output show as follows:

tp5.PNG

This creates a huge problem because I can not use other tools with that output. (Cell statistics "or others).

Note: I understand that I can use the wildcard, but this is a small example and I want to use several preconditions in the same model.

Can you please help me

Thank You Very Much

0 Kudos
3 Replies
DuncanHornby
MVP Frequent Contributor

Even thought you show it correctly in the model builder label you say your Calculate Value tool is testing the expression:

"% Name%". find ("45") !=1

Should it not be

"% Name%". find ("45") !=-1

I spoofed up the same model as you (although I was searching a folder of ASC files) and was able to replicate the same problem in ArcGIS 10.4.1. I too got an erroneous layer added in. I got rid of the Calculate Value tool and used a wild card in the iterator, this worked and only the files that fulfilled my search criteria where added to the collects Value list. So I think you would need to use the wild card approach as it looks like a bug in Modelbuilder. You could expose the wild card parameter as a parameter so you could change your search criteria if the model is run as a tool. As your model stands this is not a major change and makes it work...

0 Kudos
MarceloOyuela
New Contributor III

Thanks you for checking and confirm that it is a type of bug in model builder.

I understand about using the wildcard but i wanted something like this:

lol.PNG

Hope they fix it soon

The best Regards

0 Kudos
DuncanHornby
MVP Frequent Contributor

Looking at your image you could try splitting this up into 3 sub-models, each sub-model using the appropriate wild card feeding into the collects value tool. Just an idea?

0 Kudos