selected_locs = (["Location 1","X1234"],["Location 2","Y1234"], etc) for x in selected_locs: Cloc = x[0] drpkey = str(x[1]) outDirectionsFile = "E:/Output" + "/" + Cloc + "_Directions.xml" orders_out = "E:\\\Test.gdb\\Orders_"+ Czip routes_out = "E:\\\Test.gdb\\Routes_" + Czip arcpy.SelectLayerByAttribute_management(Geo_Orders_Layer, "NEW_SELECTION", "\"LOCATION\" = '"+ Cloc +"'") if ordrs <1: print Cloc + ": C R A S H ! ! ! ! ! ! No Deliveries Geocoded" else: print Cloc + " deliveries: " + str(ordrs) arcpy.AddLocations_na(VRP_Setup, "Orders", Geo_Orders_Layer, "Name # #;Description Full_Add #;ServiceTime SRVTIME 0.34;TimeWindowStart1 # #;TimeWindowEnd1 # #;TimeWindowStart2 # #;TimeWindowEnd2 # #;MaxViolationTime1 # #;MaxViolationTime2 # #;DeliveryQuantities # #;PickupQuantities # #;Revenue # #;SpecialtyNames CRID #;AssignmentRule # 3;RouteName # #;Sequence # #;CurbApproach # 0", "5000 Meters", "", "'SDC Edge Source' SHAPE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "'SDC Edge Source' #") Expression = "\"Name\" = '"+drpkey+"'" arcpy.SelectLayerByAttribute_management(Depots_All_Layer, "NEW_SELECTION", Expression) if pos < 1: writeLog( "\t"+drpkey + " not found. (C R A S H ! ! !)") elif pos>1: writeLog( "\t Too many Depot's found. (C R A S H ! ! !)") else: writeLog( "\t Depot found and loaded.") arcpy.AddLocations_na(VRP_Setup, "Depots", Depots_All_Layer, "Name Name #;Description Description #;TimeWindowStart1 TimeWindowStart1 #;TimeWindowEnd1 TimeWindowEnd1 #;TimeWindowStart2 TimeWindowStart2 #;TimeWindowEnd2 TimeWindowEnd2 #;CurbApproach CurbApproach 0", "5000 Meters", "", "'SDC Edge Source' SHAPE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "'SDC Edge Source' #") arcpy.AddLocations_na(VRP_Setup, "Routes", Route_Template, "Name Name #;Description Description #;StartDepotName StartDepotName #;EndDepotName EndDepotName #;StartDepotServiceTime StartDepotServiceTime #;EndDepotServiceTime EndDepotServiceTime #;EarliestStartTime EarliestStartTime '8:00:00 AM';LatestStartTime LatestStartTime '10:00:00 AM';ArriveDepartDelay ArriveDepartDelay #;Capacities Capacities #;FixedCost FixedCost #;CostPerUnitTime CostPerUnitTime 1;CostPerUnitDistance CostPerUnitDistance #;OvertimeStartTime OvertimeStartTime #;CostPerUnitOvertime CostPerUnitOvertime #;MaxOrderCount MaxOrderCount 30;MaxTotalTime MaxTotalTime #;MaxTotalTravelTime MaxTotalTravelTime #;MaxTotalDistance MaxTotalDistance #;SpecialtyNames SpecialtyNames #;AssignmentRule AssignmentRule 1", "5000 Meters", "", "'SDC Edge Source' SHAPE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "'SDC Edge Source' #") arcpy.CalculateField_management(Route_Template, "StartDepotName", "'"+drpkey+"'", "PYTHON", "") arcpy.CalculateField_management(Route_Template, "EndDepotName", "'"+drpkey+"'", "PYTHON", "") arcpy.AddLocations_na(VRP_Setup, "Breaks", Breaks_Template, "RouteName RouteName #;Precedence Precedence 1;ServiceTime ServiceTime 60;TimeWindowStart TimeWindowStart #;TimeWindowEnd TimeWindowEnd #;MaxViolationTime MaxViolationTime #;MaxTravelTimeBetweenBreaks MaxTravelTimeBetweenBreaks #;IsPaid IsPaid 1;Sequence # #;MaxCumulWorkTime # #", "5000 Meters", "", "'SDC Edge Source' SHAPE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "'SDC Edge Source' #") arcpy.AddLocations_na(VRP_Setup, "Specialties", Specialties_Template, "Name Name #;Description Description #", "5000 Meters", "", "'SDC Edge Source' SHAPE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "'SDC Edge Source' #") arcpy.Directions_na(VRP_Setup, "XML", outDirectionsFile, "Miles", "REPORT_TIME", "") arcpy.CopyFeatures_management(Orders, orders_out, "", "0", "0", "0") arcpy.CopyFeatures_management(Routes, routes_out, "", "0", "0", "0")
Traceback (most recent call last):
File "test.py", line 191, in <module>
arcpy.Directions_na(VRP_Setup, "XML", outDirectionsFile, "Miles", "REPORT_TIME", "")
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\na.py", line 440, in Directions
raise e
arcgisscripting.ExecuteError: ERROR 030092: VRP Solver failed due to invalid input.
Invalid input in the NA classes.
Failed to execute (Directions).
Solved! Go to Solution.