[GIS] Skipping an iteration in modelbuilder

arcpymodelbuilder

So I've been assigned to clean up someone else's model.

Here's the situation. The model is supposed to iterate over a few hundred folders containing feature classes and convert the contents into shapefiles. The model fails if a file called "arc" does not exist in the folder, so I need to write some python to check if it is there, and if it does not, then skip the current iteration and continue onto the next folder.

My problem is that with the way modelbuilder is set up, there is no way to skip an iteration within an iterator tool. Any ideas? I'm halfway thinking of just rewriting the whole tool in python.

Here's a screenshot of the iterator

enter image description here

It has been suggested that I use calculate value to skip an iteration. The code should be fairly simple, however how do I use the true/false output to skip an iteration?

Best Answer

I would've just commented but my rep is too low.

As Stimson has suggested, go Python. I would think that a simple if statement with the conversion process nested inside of it would work. So:

for fc in arcpy.ListFeatureClasses():
    if arcpy.Exists('arc'):
        SelectData_mb (in_dataelement, {out_dataelement})
        arcpy.CopyFeatures_management(#files to copy, outpath)
Related Question