<?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 Creating closest facility analysis layer during regression testing fails to load network layers to the map in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-closest-facility-analysis-layer-during/m-p/1601878#M12811</link>
    <description>&lt;P&gt;Hello! I am trying some unit testing using the guide on regression testing (&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Regression-Testing" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Regression-Testing&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;Part of my addin, runs a closest facility algorithm. I'm using SDK to run the geoprocess "MakeClosestFacilityAnalysisLayer".&lt;/P&gt;&lt;P&gt;When I run it normally using the UI, it all works perfectly.&lt;/P&gt;&lt;P&gt;When I'm running it using regression testing, the geoprocess is successful with no errors/warnings, however, the Network Analysis Layer is not loaded to my active map. I have set an active map programmatically, and I have confirmed that the Closest Facility feature dataset is created in my default gdb, however, since it's not loaded to the map, I can't seem to actually load data to it or run it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal static async Task&amp;lt;string&amp;gt; MakeAnalysisLayer(string network, string layer_name, ClosestFacilitySettings settings)
{
    string actual_layer_name = layer_name;
    int i = 1;
    while (MapView.Active.Map.FindLayers(actual_layer_name).Count &amp;gt; 0)
    {
        actual_layer_name = layer_name + "_" + i.ToString();
        i++;
    }


    var env = Geoprocessing.MakeEnvironmentArray(workspace: Project.Current.DefaultGeodatabasePath);

    var MakeClosestFacilityAnalysisLayerParameters = Geoprocessing.MakeValueArray(
        network,
        actual_layer_name,
        settings.travel_mode,
        settings.travel_direction.ToString(),
        settings.cutoff,
        settings.numberOfFacilities
        );

    var mcfalResult = await Geoprocessing.ExecuteToolAsync("MakeClosestFacilityAnalysisLayer", MakeClosestFacilityAnalysisLayerParameters, env, flags: GPExecuteToolFlags.AddOutputsToMap);

    return mcfalResult.ReturnValue;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the debugger, I'm seeing identical parameters, env values, network etc. The only difference is that the result is not loaded to the map.&lt;/P&gt;&lt;P&gt;I can't seem to fix it or find a workaround to make it work, not even a "hacky" one. Is this intended behavior, and if so, what's the proper way to do what I'm trying to do?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Apr 2025 15:21:43 GMT</pubDate>
    <dc:creator>FanisDeligiannis</dc:creator>
    <dc:date>2025-04-02T15:21:43Z</dc:date>
    <item>
      <title>Creating closest facility analysis layer during regression testing fails to load network layers to the map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-closest-facility-analysis-layer-during/m-p/1601878#M12811</link>
      <description>&lt;P&gt;Hello! I am trying some unit testing using the guide on regression testing (&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Regression-Testing" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Regression-Testing&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;Part of my addin, runs a closest facility algorithm. I'm using SDK to run the geoprocess "MakeClosestFacilityAnalysisLayer".&lt;/P&gt;&lt;P&gt;When I run it normally using the UI, it all works perfectly.&lt;/P&gt;&lt;P&gt;When I'm running it using regression testing, the geoprocess is successful with no errors/warnings, however, the Network Analysis Layer is not loaded to my active map. I have set an active map programmatically, and I have confirmed that the Closest Facility feature dataset is created in my default gdb, however, since it's not loaded to the map, I can't seem to actually load data to it or run it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal static async Task&amp;lt;string&amp;gt; MakeAnalysisLayer(string network, string layer_name, ClosestFacilitySettings settings)
{
    string actual_layer_name = layer_name;
    int i = 1;
    while (MapView.Active.Map.FindLayers(actual_layer_name).Count &amp;gt; 0)
    {
        actual_layer_name = layer_name + "_" + i.ToString();
        i++;
    }


    var env = Geoprocessing.MakeEnvironmentArray(workspace: Project.Current.DefaultGeodatabasePath);

    var MakeClosestFacilityAnalysisLayerParameters = Geoprocessing.MakeValueArray(
        network,
        actual_layer_name,
        settings.travel_mode,
        settings.travel_direction.ToString(),
        settings.cutoff,
        settings.numberOfFacilities
        );

    var mcfalResult = await Geoprocessing.ExecuteToolAsync("MakeClosestFacilityAnalysisLayer", MakeClosestFacilityAnalysisLayerParameters, env, flags: GPExecuteToolFlags.AddOutputsToMap);

    return mcfalResult.ReturnValue;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the debugger, I'm seeing identical parameters, env values, network etc. The only difference is that the result is not loaded to the map.&lt;/P&gt;&lt;P&gt;I can't seem to fix it or find a workaround to make it work, not even a "hacky" one. Is this intended behavior, and if so, what's the proper way to do what I'm trying to do?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 15:21:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-closest-facility-analysis-layer-during/m-p/1601878#M12811</guid>
      <dc:creator>FanisDeligiannis</dc:creator>
      <dc:date>2025-04-02T15:21:43Z</dc:date>
    </item>
  </channel>
</rss>

