<?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 Re: Incorrect Zoom-to Scale After AddSpatialIndex in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/incorrect-zoom-to-scale-after-addspatialindex/m-p/1413492#M11398</link>
    <description>&lt;P&gt;Have you called&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic20822.html" target="_self"&gt;the map view redraw&amp;nbsp;&lt;/A&gt;after the index update?&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 14:52:16 GMT</pubDate>
    <dc:creator>Aashis</dc:creator>
    <dc:date>2024-04-22T14:52:16Z</dc:date>
    <item>
      <title>Incorrect Zoom-to Scale After AddSpatialIndex</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/incorrect-zoom-to-scale-after-addspatialindex/m-p/1412502#M11394</link>
      <description>&lt;P&gt;I'm building an Add-in in ArcGIS Pro 3.2.2 and working on fixing the zoom-to extent after an imported 3D object (.OBJ file) multipatch geodatabase feature class has been moved to a set lat/long/elevation. When the object has been moved, the zoom scale becomes extreme (about the size of Africa) when moved from the original location (0, 0) to France (2, 48). This can be fixed within the ArcGIS UI by using the "Add Spatial Index" geoprocessing tool. However, when attempting to use this tool within the .NET SDK or using ArcPy, the spatial index is fixed, but only after closing ArcGIS Pro and opening the project back up.&lt;/P&gt;&lt;P&gt;public static async Task AddSpatialIndexAsync(string featureClassPath)&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;var arguments = Geoprocessing.MakeValueArray(featureClassPath);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;IGPResult result = await Geoprocessing.ExecuteToolAsync("management.AddSpatialIndex", arguments);&lt;/P&gt;&lt;P&gt;if (result.IsFailed)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;System.Diagnostics.Debug.WriteLine("Failed to add spatial index: " + result.ErrorCode);&lt;BR /&gt;foreach (var msg in result.Messages)&lt;BR /&gt;System.Diagnostics.Debug.WriteLine(msg.Text);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;System.Diagnostics.Debug.WriteLine("Spatial index added successfully.");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;System.Diagnostics.Debug.WriteLine("Error adding spatial index: " + ex.Message);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;What's the difference between using the Geoprocessing tool directly and calling the Geoprocessing tool from the .NET SDK?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 19:51:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/incorrect-zoom-to-scale-after-addspatialindex/m-p/1412502#M11394</guid>
      <dc:creator>ARO</dc:creator>
      <dc:date>2024-04-19T19:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Zoom-to Scale After AddSpatialIndex</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/incorrect-zoom-to-scale-after-addspatialindex/m-p/1413492#M11398</link>
      <description>&lt;P&gt;Have you called&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic20822.html" target="_self"&gt;the map view redraw&amp;nbsp;&lt;/A&gt;after the index update?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 14:52:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/incorrect-zoom-to-scale-after-addspatialindex/m-p/1413492#M11398</guid>
      <dc:creator>Aashis</dc:creator>
      <dc:date>2024-04-22T14:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Zoom-to Scale After AddSpatialIndex</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/incorrect-zoom-to-scale-after-addspatialindex/m-p/1413622#M11400</link>
      <description>&lt;P&gt;Yeah, I've tried that. Here's a list of various attempts at clearing caches, refreshing, and redrawing:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public static void ForceRefreshLayer(FeatureLayer featureLayer)
        {
            if (featureLayer != null)
            {
                // Toggle visibility

                QueuedTask.Run(() =&amp;gt; { featureLayer.SetVisibility(false); });
                System.Threading.Thread.Sleep(100); // Short delay to ensure UI updates
                QueuedTask.Run(() =&amp;gt; { featureLayer.SetVisibility(true); });

                MapView.Active.Invalidate(featureLayer, null);
                QueuedTask.Run(() =&amp;gt; { MapView.Active.Redraw(true); });

                QueuedTask.Run(() =&amp;gt;
                {
                    var renderer = featureLayer.GetRenderer();
                    featureLayer.SetRenderer(null);
                    System.Threading.Thread.Sleep(100); // Let UI catch up
                    featureLayer.SetRenderer(renderer);
                });

                var dbConnection = Project.Current.GetGeodatabases();
                QueuedTask.Run(() =&amp;gt; dbConnection.Refresh());

                var contentItem = Project.Current.GetItems&amp;lt;FolderConnectionProjectItem&amp;gt;().First();
                if (contentItem.IsMainThreadRequired)
                {
                    //QueuedTask.Run must be used if item.IsMainThreadRequired
                    //returns true
                    QueuedTask.Run(() =&amp;gt; contentItem.Refresh());
                }
                else
                {
                    contentItem.Refresh();

                    ArcGIS.Core.Threading.Tasks.BackgroundTask.Run(() =&amp;gt;
                      contentItem.Refresh(), ArcGIS.Core.Threading.Tasks.BackgroundProgressor.None);
                }
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Apr 2024 17:26:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/incorrect-zoom-to-scale-after-addspatialindex/m-p/1413622#M11400</guid>
      <dc:creator>ARO</dc:creator>
      <dc:date>2024-04-22T17:26:52Z</dc:date>
    </item>
  </channel>
</rss>

