I am running a script which takes some input parameters and runs some Network Analyst processes. The script is imported into a toolbox and is setup in Model Builder with the necessary input and output parameters.
My problem is that I am struggling to understand how to get the resulting Solve operation back out of the script and into Model Builder for subsequent work.
Here is my script:
# Import arcpy module
import arcpy
# Check out any necessary licenses
arcpy.CheckOutExtension("Network")
# Script arguments
Network_Dataset = arcpy.GetParameterAsText(0) # Network dataset layer
Input_Locations = arcpy.GetParameterAsText(1) # Layer file
Output_Path = arcpy.GetParameterAsText(2) # Output path
# Local variables:
#Solve_Succeeded = Network_Analyst_Layer__3_
#Output_derived_feature_class = Network_Dataset
arcpy.AddMessage("Creating the Origin Destination layer...")
# Process: Make OD Cost Matrix Layer
arcpy.MakeODCostMatrixLayer_na(Network_Dataset, "odMatrix", "Length", "100", "", "", "ALLOW_UTURNS", "", "", "", "NO_LINES", "")
arcpy.AddMessage("Calculating Locations. This may take a while...")
# Process: Calculate Locations
arcpy.CalculateLocations_na(Input_Locations, Network_Dataset, "500 Meters", [["Streets","SHAPE"],["Streets_ND_Junctions","NONE"]] , "MATCH_TO_CLOSEST", "", "", "", "", "", "", "", "", "", "INCLUDE", "")
arcpy.AddMessage("Adding locations to Origin Destination layer...")
# Process: Add Locations to Origins Sub-Layer
arcpy.AddLocations_na("odMatrix", "Origins", Input_Locations, "", "500 Meters", "", "", "MATCH_TO_CLOSEST", "APPEND", "", "", "INCLUDE", "")
# Process: Add Locations to Destinations Sub-Layer
arcpy.AddLocations_na("odMatrix", "Destinations", Input_Locations, "", "500 Meters", "", "", "MATCH_TO_CLOSEST", "APPEND", "", "", "INCLUDE", "")
arcpy.AddMessage("Starting Network Analysis solve...")
# Process: Solve
arcpy.Solve_na("odMatrix", "SKIP", "TERMINATE", "")
arcpy.AddMessage("Network analysis completed.")
# How to get this out of script???
# Return as model output parameter
arcpy.SetParameterAsText(3, outputTable)