AnsweredAssumed Answered

Arcpy Closest Facility Layer unable to retrieve CFRoutes table

Question asked by toonant on Nov 18, 2013
Latest reply on Nov 20, 2013 by toonant
I am using the following code to make a Closest Facility layer, which I then want to output the CFRoutes table to use in a SearchCursor:

    import arcpy, os, sys          from arcpy import env          arcpy.env.workspace = "C:\\Users\\Ant\\Documents\\ArcGIS\\ITN.gdb"     arcpy.RefreshCatalog("C:\\Users\\Ant\\Documents\\ArcGIS\\ITN.gdb")     env.overwriteOutput = True     inNetworkDataset = "C:\Users\Ant\Documents\ArcGIS\OSMaster.gdb\ITN_Network\ITN_NetworkDataset"     impedanceAttribute = "Drive"     searchTolerance = "5000 Meters"     accumulateAttributeName = ["Length", "Drive"]     inFacilities = "TL_chemistsV3"     inIncidents = "BLPUs_Points"     outLayerFile = "ProxChemistsCF.lyr"     outNALayer =, "ProxChemistsCF", impedanceAttribute, "TRAVEL_TO", "", 1, accumulateAttributeName, "NO_UTURNS", "", "", "", "TRUE_LINES_WITHOUT_MEASURES")     outNALayer = outNALayer.getOutput(0)     subLayerNames =     facilitiesLayerName = subLayerNames["Facilities"]     incidentsLayerName = subLayerNames["Incidents"], facilitiesLayerName, inFacilities, "", searchTolerance), incidentsLayerName, inIncidents, "", searchTolerance)     tableName = subLayerNames["CFRoutes"]     if arcpy.Exists("ProxChemists"):         arcpy.Delete_management("ProxChemists")     outTable = "ProxChemists"     arcpy.CopyRows_management(tableName, outTable)

but the last line fails with error message:

    ExecuteError: Failed to execute. Parameters are not valid.     ERROR 000732: Input Rows: Dataset Routes does not exist or is not supported     Failed to execute (CopyRows).

But the dataset I am inputting is CFRoutes, not Routes as per this line tableName = subLayerNames["CFRoutes"]

I tried skipping the CopyRows and jumping straight into the search cursor using this:

    with arcpy.da.UpdateCursor("BLPUs", ["FID", "ChemistsFID", "ChemistsDist", "ChemistsDrive"]) as cursor:         for row in cursor:             OID1 = str(int(row[0]))             searchrows = arcpy.da.SearchCursor(tableName, ["ObjectID", "FacilityID", "Total_Drive", "Total_Length"])             for searchrow in searchrows:                 searchrow1 = str(int(searchrow[0]))                 searchrow2 = str(int(searchrow[1]))                 searchrow3 = str(float(searchrow[2]))                 searchrow4 = str(float(searchrow[3]))                 if searchrow1 == OID1:                     row[1] = searchrow2                     row[2] = searchrow4                     row[3] = searchrow3                     cursor.updateRow(row)

But the error is 'RuntimeError: cannot open 'Routes''

So I guess calling CFRoutes tries to open the sub-table Routes intentionally but is failing, have I missed something out? Is the Closest Facility layer not actually being created?