Struggling to create a FGDB line feature from a Network Analyst arcpy.Solve_na() comm

Discussion created by mimiller on Nov 13, 2012
I've setup a python file that takes a network data set and a stop file (begin and end points) and solves the route. What I need to do now is create a polyline data set in a scratch FGDB.

Suggestions welcome.

class LicenseError(Exception):

import arcpy, time
from arcpy import env
import os
arcpy.env.overwriteOutput = 1

# set variables/parameters
scratch = r"\\itdhq1app60\GIS_Data\RoutingWebApp\Scratch.gdb"
netWSpace = r"\\itdgishq\hqgis\NetAnalyst\MACS_Files.gdb\Routes"
stopWS = r"\\itdgishq\hqgis\NetAnalyst\MACS_Files.gdb"
inNet = r"\\itdgishq\hqgis\NetAnalyst\MACS_Files.gdb\Routes\Roads_ND"
outNet = "outRoute"
impedanceAttribute = "Time"
accumulateAttribute = ['Time', 'Miles']
parameterizedAttribute = "HeightRestriction"
restrictions = ["Oneway", parameterizedAttribute]
parameterName = "Vehicle Height"
truckHeight = 15
stopPts = "Stop2a"
stopFilePath = stopWS + os.sep + stopPts
fieldMappings = "Name Name #; SourceID SourceID #; SourceOID SourceOID #; PosAlong PosAlong #; SideOfEdge SideOfEdge #"
outLayerFile = r"\\itdhq1app60\gis_data\RoutingWebApp\layers" + os.sep + outNet + "_" + stopPts + ".lyr"

print outLayerFile

# license test, checking Network license Available
    if arcpy.CheckExtension("Network") == "Available":
        # Raise a custom exception
        raise LicenseError

    #print netlayer
    arcpy.env.workspace = netWSpace
    l_nwds = arcpy.ListDatasets("*", "Network")
    print "Network Datasets:"
    print l_nwds
    #arcpy.env.workspace = scratch
    arcpy.MakeRouteLayer_na(inNet, outNet, impedanceAttribute, "", "", "", accumulateAttribute, "ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLY", restrictions, "USE_HIERARCHY")
    arcpy.UpdateAnalysisLayerAttributeParameter_na(outNet, parameterizedAttribute, parameterName, truckHeight)
    arcpy.AddLocations_na(outNet, "Stops", stopFilePath, fieldMappings)
    arcpy.Solve_na(outNet, "HALT", "TERMINATE")
    arcpy.SaveToLayerFile_management(outNet,outLayerFile, "RELATIVE")

    # What command to create feature class??
except LicenseError:
    print "************** Network Analyst license is unavailable **************"

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)   

    # Check in the 3D Analyst extension