GetSolverProperties (arcpy.na)

Summary

Returns a Network Analyst solver properties object based on the type of the Network Analyst layer specified as the argument. The solver properties object is used to update the analysis properties for the layer.

Discussion

GetSolverProperties acts as the main entry point when modifying the analysis properties of a Network Analyst layer. It returns a separate solver properties object based on the Network Analyst layer. There are six types of solver properties objects: RouteSolverProperties, ClosestFacilitySolverProperties, ServiceAreaSolverProperties, ODCostMatrixSolverProperties, VehicleRoutingProblemSolverProperties, and LocationAllocationSolverProperties. Each solver properties object provides read/write access to the analysis properties specific to a Network Analyst layer.

Syntax

GetSolverProperties (network_analyst_layer)
ParameterExplanationData Type
network_analyst_layer

A variable that references a layer object obtained from a Network Analyst layer. It can be derived from existing layers in a map document or by specifying the catalog path to the Network Analyst layer file as an argument to the Layer class. The isNetworkAnalystLayer property on the layer object can be used to identify whether a given layer object is a Network Analyst layer.

Layer
Return Value
Data TypeExplanation
Object

A solver properties object corresponding to the type of the Network Analyst layer.

Code Sample

GetSolverProperties example

This example shows how to find all Network Analyst layers in a map document and change their analysis properties such that they all use hierarchy. It assumes that some Network Analyst layers are already added to a map document.

import arcpy

#Get a list of all the layers in the current map document
mxd = arcpy.mapping.MapDocument("CURRENT")
lyrs = arcpy.mapping.ListLayers(mxd)
#Filter the list to obtain only the network analyst layers
na_layers = [lyr for lyr in lyrs if lyr.isNetworkAnalystLayer]
#update the useHierarchy property
for na_layer in na_layers:
    na_solver_props = arcpy.na.GetSolverProperties(na_layer)
    na_solver_props.useHierarchy = True
2/10/2012