<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help returning path object from Network Analysis Layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-returning-path-object-from-network-analysis/m-p/1304730#M68073</link>
    <description>&lt;P&gt;Help - I'm trying to get the path to the "Routes" sub-layer of the Network Analysis layer created on Line 2, but can't figure out how to pass that information through to the correct variable (feature class identified at Line 52 and used at Lines&amp;nbsp;62 &amp;amp; 86). I suspect I'm not using the arcpy.Describe function correctly. What should I be using instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Create route analysis layer and solve routes
    RAL = arcpy.na.MakeRouteAnalysisLayer(
        network_data_source = nd_path,
        layer_name = nd_layer_name,
        travel_mode = travelmode,
        sequence = "USE_CURRENT_ORDER",
        time_of_day = None,
        time_zone = "LOCAL_TIME_AT_LOCATIONS",
        line_shape = "ALONG_NETWORK",
        accumulate_attributes = None,
        generate_directions_on_solve = "DIRECTIONS",
        time_zone_for_time_fields = "LOCAL_TIME_AT_LOCATIONS",
        ignore_invalid_locations = "SKIP"
    )
    print ("Route analysis layer created")

    # Get the layer object from the Route Analysis Layer result object.
    # The route layer can now be referenced using the layer object.
    layer_object = RAL.getOutput(0)

    # Get the names of all the sublayers within the route layer.
    sublayer_names = arcpy.na.GetNAClassNames(layer_object)

    # Stores the layer names that we will use later
    routes_layer_name = sublayer_names["Routes"]

    # Instantiate a ServiceArea analysis object.
    service_area = arcpy.nax.ServiceArea(nd_path)
    print ("Service area set")

    # Get the desired travel mode for the analysis.
    nd_travel_modes = arcpy.nax.GetTravelModes(nd_path)
    travel_mode = nd_travel_modes[travelmode]
    print ("Travel mode acquired")

    # Set properties.
    service_area.timeUnits = arcpy.nax.TimeUnits.Minutes
    service_area.defaultImpedanceCutoffs = [5, 10, 15]
    service_area.travelMode = travel_mode
    service_area.outputType = arcpy.nax.ServiceAreaOutputType.Polygons
    service_area.geometryAtOverlap = arcpy.nax.ServiceAreaOverlapGeometry.Split
    print ("Network Analysis properties set. Adding locations...")

# Unrelated code removed...

    print ("Routes calculated")

    arcpy.CheckInExtension("Network")
    print ("Network Analyst license checked-in")

    ####################### Append data #######################
    datasets = arcpy.ListDatasets(feature_type='feature')
    datasets = [''] + datasets if datasets is not None else []

    for ds in datasets:
        for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
            path = os.path.join(arcpy.env.workspace, ds, fc)
            if (str(os.path.splitext(fc)[0])[:6]) == "Routes": ##### &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; This finds the Routes sublayer in the geodatabase\network dataset and assigns it to variable 'fc'
                print ("Routes found - start append process")

                # Variables - do not update
                fcpath = arcpy.Describe(fc) ###### &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; This is where I am trying to get the path to variable 'fc'
                fc = str(fcpath)                           # Path to Feature Class
                fsItemId = outfsID                              # Feature Service Item ID to update
                layerIndex = sublayerID                         # Layer Index

                # Create UUID variable for GDB
                gdbId = str(uuid.uuid1())

                # Function to Zip FGD
                def zipDir(dirPath, zipPath):
                    '''Zip File Geodatabase'''
                    zipf = ZipFile(zipPath , mode='w')
                    gdb = os.path.basename(dirPath)
                    for root, _ , files in os.walk(dirPath):
                        for file in files:
                            if 'lock' not in file:
                               filePath = os.path.join(root, file)
                               zipf.write(filePath , os.path.join(gdb, file))
                    zipf.close()

                print("Creating temporary File Geodatabase")
                gdb = arcpy.CreateFileGDB_management(arcpy.env.scratchFolder, gdbId)[0]

                # Export feature class to temporary File Geodatabase
                fcName = os.path.basename(fc) ###### &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; So that I can use the pathway here
                fcName = fcName.split('.')[-1]
                print(f"Exporting {fcName} to temp FGD")
                arcpy.conversion.ExportTable(fc, gdb + "\\" + fcName) # &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current error from results below:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Creating temporary File Geodatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;Exporting &amp;lt;geoprocessing describe data object object at 0x000001AE661C6070&amp;gt; to temp FGD&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Script failed - email notification sent to gis@fpc.wa.gov.au&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Exception: Failed to execute. Parameters are not valid.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;ERROR 000732: Input Table: Dataset &amp;lt;geoprocessing describe data object object at 0x000001AE661C6070&amp;gt; does not exist or is not supported&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;ERROR 000354: The name contains invalid characters&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;Failed to execute (ExportTable).&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jun 2023 00:53:44 GMT</pubDate>
    <dc:creator>LindsayRaabe_FPCWA</dc:creator>
    <dc:date>2023-06-30T00:53:44Z</dc:date>
    <item>
      <title>Help returning path object from Network Analysis Layer</title>
      <link>https://community.esri.com/t5/python-questions/help-returning-path-object-from-network-analysis/m-p/1304730#M68073</link>
      <description>&lt;P&gt;Help - I'm trying to get the path to the "Routes" sub-layer of the Network Analysis layer created on Line 2, but can't figure out how to pass that information through to the correct variable (feature class identified at Line 52 and used at Lines&amp;nbsp;62 &amp;amp; 86). I suspect I'm not using the arcpy.Describe function correctly. What should I be using instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Create route analysis layer and solve routes
    RAL = arcpy.na.MakeRouteAnalysisLayer(
        network_data_source = nd_path,
        layer_name = nd_layer_name,
        travel_mode = travelmode,
        sequence = "USE_CURRENT_ORDER",
        time_of_day = None,
        time_zone = "LOCAL_TIME_AT_LOCATIONS",
        line_shape = "ALONG_NETWORK",
        accumulate_attributes = None,
        generate_directions_on_solve = "DIRECTIONS",
        time_zone_for_time_fields = "LOCAL_TIME_AT_LOCATIONS",
        ignore_invalid_locations = "SKIP"
    )
    print ("Route analysis layer created")

    # Get the layer object from the Route Analysis Layer result object.
    # The route layer can now be referenced using the layer object.
    layer_object = RAL.getOutput(0)

    # Get the names of all the sublayers within the route layer.
    sublayer_names = arcpy.na.GetNAClassNames(layer_object)

    # Stores the layer names that we will use later
    routes_layer_name = sublayer_names["Routes"]

    # Instantiate a ServiceArea analysis object.
    service_area = arcpy.nax.ServiceArea(nd_path)
    print ("Service area set")

    # Get the desired travel mode for the analysis.
    nd_travel_modes = arcpy.nax.GetTravelModes(nd_path)
    travel_mode = nd_travel_modes[travelmode]
    print ("Travel mode acquired")

    # Set properties.
    service_area.timeUnits = arcpy.nax.TimeUnits.Minutes
    service_area.defaultImpedanceCutoffs = [5, 10, 15]
    service_area.travelMode = travel_mode
    service_area.outputType = arcpy.nax.ServiceAreaOutputType.Polygons
    service_area.geometryAtOverlap = arcpy.nax.ServiceAreaOverlapGeometry.Split
    print ("Network Analysis properties set. Adding locations...")

# Unrelated code removed...

    print ("Routes calculated")

    arcpy.CheckInExtension("Network")
    print ("Network Analyst license checked-in")

    ####################### Append data #######################
    datasets = arcpy.ListDatasets(feature_type='feature')
    datasets = [''] + datasets if datasets is not None else []

    for ds in datasets:
        for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
            path = os.path.join(arcpy.env.workspace, ds, fc)
            if (str(os.path.splitext(fc)[0])[:6]) == "Routes": ##### &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; This finds the Routes sublayer in the geodatabase\network dataset and assigns it to variable 'fc'
                print ("Routes found - start append process")

                # Variables - do not update
                fcpath = arcpy.Describe(fc) ###### &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; This is where I am trying to get the path to variable 'fc'
                fc = str(fcpath)                           # Path to Feature Class
                fsItemId = outfsID                              # Feature Service Item ID to update
                layerIndex = sublayerID                         # Layer Index

                # Create UUID variable for GDB
                gdbId = str(uuid.uuid1())

                # Function to Zip FGD
                def zipDir(dirPath, zipPath):
                    '''Zip File Geodatabase'''
                    zipf = ZipFile(zipPath , mode='w')
                    gdb = os.path.basename(dirPath)
                    for root, _ , files in os.walk(dirPath):
                        for file in files:
                            if 'lock' not in file:
                               filePath = os.path.join(root, file)
                               zipf.write(filePath , os.path.join(gdb, file))
                    zipf.close()

                print("Creating temporary File Geodatabase")
                gdb = arcpy.CreateFileGDB_management(arcpy.env.scratchFolder, gdbId)[0]

                # Export feature class to temporary File Geodatabase
                fcName = os.path.basename(fc) ###### &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; So that I can use the pathway here
                fcName = fcName.split('.')[-1]
                print(f"Exporting {fcName} to temp FGD")
                arcpy.conversion.ExportTable(fc, gdb + "\\" + fcName) # &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current error from results below:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Creating temporary File Geodatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;Exporting &amp;lt;geoprocessing describe data object object at 0x000001AE661C6070&amp;gt; to temp FGD&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Script failed - email notification sent to gis@fpc.wa.gov.au&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Exception: Failed to execute. Parameters are not valid.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;ERROR 000732: Input Table: Dataset &amp;lt;geoprocessing describe data object object at 0x000001AE661C6070&amp;gt; does not exist or is not supported&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;ERROR 000354: The name contains invalid characters&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;Failed to execute (ExportTable).&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 00:53:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-returning-path-object-from-network-analysis/m-p/1304730#M68073</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2023-06-30T00:53:44Z</dc:date>
    </item>
  </channel>
</rss>

