How to access the Route sublayer properties in arcpy

Discussion created by fst77 on Jun 30, 2013
Latest reply on Jul 2, 2013 by fst77
After solving a route, I need to read the properties of the Route class. Concretely the Total_[Impedance] field as I want to compare different routes with regard to this attribute. Is there any way to do this with arcpy?

My code until this step is typical:

route_lyr = arcpy.na.MakeRouteLayer(nwork,"BestRoute", "Length", output_path_shape="TRUE_LINES_WITH_MEASURES")
route_lyr = route_lyr.getOutput(0)
sub_layers = arcpy.na.GetNAClassNames(route_lyr)

Then I thought about the following to get the Total_Length value of the solve result:

for lyr in arcpy.mapping.ListLayers(route_lyr):
    [INDENT]if lyr.name == "Routes":
        [INDENT]print lyr.longName                                      # Printed just for explanatory purposes
        sCursor = arcpy.SearchCursor(lyr.longName)   # "BestRoute\Routes" is passed. The error is thrown here
        while sCursor:
            [INDENT]row = sCursor.next()
            cost = row.getValue("Total_Length")
            print cost[/INDENT]

Which prints to standard output:

An error occurred on line XXX
"BestRoute\Routes" does not exist

So "BestRoute\Routes" is the long name of the Routes layer but (apparently) not the input that SearchCursor expects. Generic layer properties (longName, isBroken...) can be accessed with my code, but not those network-related.

I guess I'm missing the mechanism to access the network properties of the sublayer Routes that is stored in the composite layer...

Any help would be much appreciated.