AnsweredAssumed Answered

Stop loop when empty feature class is generated.

Question asked by wtgeographer on Jun 3, 2014
Latest reply on Jun 5, 2014 by wtgeographer
I am trying to stop the script below once an empty feature class is generated.  I have worked out the following which I imagine to be close? But still receive an error:

ExecuteError: ERROR 010151: No features found in G:\Xcel\Route Tool\Southwest\Results.gdb\LCP_4. Possible empty feature class

I think the script should explain what I am trying to accomplish?

         count = 0      while count < 10:          Output_polyline =  os.path.join(savepath  + "\\Results.gdb"  + "\\LCP_" + str(count))         End_Raster =  os.path.join(savepath  + "\\Scratch.gdb"  + "\\End_Raster_" + str(count))          #Raster to Polyline         arcpy.AddMessage("Saving Least Cost Path {0}..." .format(count + 1))         arcpy.RasterToPolyline_conversion(get_LCP(count), Output_polyline, "ZERO", "0", "SIMPLIFY", "")              # List line feature classes in Results.gdb         fclist = arcpy.ListFeatureClasses("*","Line",savepath  + "\\Results.gdb")         for fc in fclist:             lcpcount = arcpy.GetCount_management(fc)              if lcpcount == 0:                 break

Outcomes