1

I'm having trouble debugging my python code to create a network analyst layer in ArcGIS 10.0. Basically when run from a script tool the code completes successfully without actually doing anything or returning any sort of useful information, and when run from the embedded python window in ArcGIS 10.0 i get the following error.

"Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000192: Invalid value for Time Attribute Failed to execute (MakeVehicleRoutingProblemLayer)."

The script is supposed to solve the route and create a layer file for the output Here is my code below:

#Import system modules
import arcpy
from arcpy import env
try:
 #Check out the Network Analyst extension license
 arcpy.CheckOutExtension("Network")
 #Set environment settings
 env.workspace = r'C:\Layout3.gdb'
 env.overwriteOutput = True
 #Set local variables
 inNetworkDataset = r'C:\Layout3.gdb\NtsFDS\NtsFDS_ND'
 outNALayerName = "TestResult"
 
 impedanceAttribute = "CABLE_COST"
 distanceAttribute = "TRAVEL_TIME"
 timeUntis = "Minutes"
 distanceUntis = "Meters"
 inOrders = r'\Layout3.gdb\NtsFDS\Orders'
 inDepots = r'C:\Layout3.gdb\NtsFDS\Depots'
 inRoutes = r'C:\Layout3.gdb\NtsFDS\Route'
 outLayerFile = env.workspace + outNALayerName + ".lyr"
 
 outNALayer = arcpy.na.MakeVehicleRoutingProblemLayer(inNetworkDataset, outNALayerName,
 impedanceAttribute,
 distanceAttribute)
 
 outNALayer = outNALayer.getOutput(0)
 
 subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
 
 ordersLayerName = subLayerNames["Orders"]
 depotsLayerName = subLayerNames["Depots"]
 routesLayerName = subLayerNames["Routes"]
 
 candidateFields = arcpy.ListFields(inOrders)
 orderFieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, ordersLayerName,
 False, candidateFields)
 arcpy.na.AddLocations(outNALayer, ordersLayerName, inOrders, orderFieldMappings,"")
 
 depotFieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, depotsLayerName)
 arcpy.na.AddLocations(outNALayer, depotsLayerName, inDepots, depotFieldMappings, "")
 
 arcpy.na.AddLocations(outNALayer, routesLayerName, inRoutes, "", "")
 
 #Solve the VRP layer
 arcpy.na.Solve(outNALayer)
 
 #Save the solved VRP layer as a layer file on disk with relative paths
 arcpy.management.SaveToLayerFile(outNALayer,outLayerFile,"RELATIVE")
 
 print "Script completed successfully"
except Exception as e:
 # If an error occurred, print line number and error message
 import traceback, sys
 tb = sys.exc_info()[2]
 print "An error occured on line %i" % tb.tb_lineno
 print str(e)
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked May 14, 2013 at 7:33
0

1 Answer 1

2

For this code to run you will need to upgrade to ArcGIS Desktop 10.1 because the ArcPy Network Analyst module (arcpy.na) was only introduced at that release - see What's new for geoprocessing in ArcGIS 10.1.

answered May 14, 2013 at 8:08
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.