<?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: ArcGIS Pro hangs on layout added by code and when map frame is activated in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1025357#M6161</link>
    <description>&lt;P&gt;Thank you for your suggestion. The problem is, I still have to get the layout from the LayoutProjectItem with GetLayout(); But at least the ImportItem option is faster than to get the item first and then open it. Anyway the layout only hangs when I'm activating the mapframe.&lt;/P&gt;&lt;P&gt;But what I tested now, is to open a layout first with the import layout from the catalog pane and then opening a layout with my code. The interesting thing is, my layout opened by code doesn't hang when I open one with the catalog option first.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2021 15:02:47 GMT</pubDate>
    <dc:creator>MyriamFischer</dc:creator>
    <dc:date>2021-02-10T15:02:47Z</dc:date>
    <item>
      <title>ArcGIS Pro hangs on layout added by code and when map frame is activated</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1024943#M6150</link>
      <description>&lt;P&gt;I'm working with ArcGIS Pro 2.6 and when I add a layout by code and activate the mapframe in the layout, it is not responding any longer. The ribbons are grayed out and the Layout cannot be reactivated. When I import the same layout from the catalog pane, it is working correctly. There is just one default layer in the map on the layout. When I wait long enough I can close the map frame and return to the layout. To activate the map frame now is not a problem any more.&lt;/P&gt;&lt;P&gt;Code for adding the layout:&lt;/P&gt;&lt;P&gt;var layout&amp;nbsp; = await QueuedTask.Run(() =&amp;gt; GetLayout(selectedLayoutPath, name));&lt;/P&gt;&lt;P&gt;private Layout GetLayout(string path, string layoutname)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;var pathDef = string.Concat(path, @"\", layoutname, @".pagx");&lt;BR /&gt;&lt;BR /&gt;var layoutItem = Project.Current.GetItems&amp;lt;LayoutProjectItem&amp;gt;().FirstOrDefault(item =&amp;gt; item.Name.Equals(layoutname));&lt;BR /&gt;if (layoutItem != null)&lt;BR /&gt;{&lt;BR /&gt;Project.Current.RemoveItem(layoutItem);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var pagx = (IProjectItem)ItemFactory.Instance.Create(pathDef);&lt;BR /&gt;Project.Current.AddItem(pagx);&lt;BR /&gt;layoutItem = Project.Current.GetItems&amp;lt;LayoutProjectItem&amp;gt;().FirstOrDefault(item =&amp;gt; item.Name.Equals(layoutname));&lt;BR /&gt;return layoutItem.GetLayout();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Is there another method to add a layout to the project or is it a known bug? I saw other posts with problems on changing map frames on layouts.&lt;/P&gt;&lt;P&gt;I also used the ArcGIS Diagnostic Monitor and the process bugged on&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;ArcGIS.Desktop.Internal.Layouts.Ribbon.MapSeriesGalleryItem.RefreshAsync+&lt;BR /&gt;100 05:23:41:595 &lt;STRONG&gt;431439&lt;/STRONG&gt; 431439 0 0&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope somebody can tell me what the problem is.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 17:02:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1024943#M6150</guid>
      <dc:creator>MyriamFischer</dc:creator>
      <dc:date>2021-02-09T17:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro hangs on layout added by code and when map frame is activated</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1025101#M6152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've executed your code on&amp;nbsp;&lt;SPAN&gt;ArcGIS Pro 2.7 and it's working fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;-Prashant&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 23:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1025101#M6152</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-02-09T23:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro hangs on layout added by code and when map frame is activated</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1025167#M6157</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/14738"&gt;@MyriamFischer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I have also encountered similar issue before.&lt;/P&gt;&lt;P&gt;The problem is at&amp;nbsp; &amp;nbsp;&amp;gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;return layoutItem.GetLayout();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I debug, I noticed layoutItem is null sometime.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Since it is in async and didn't catch error, you got that error message.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It might be because of async thread issue, after item is added, we cannot retrieved straight.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I have done workaround by project item change event and capture the added item.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After that quickly unsubscribed it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;here is the code snippet, I used before -&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; this.ProjectItemChangeSubscription = ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe(this.CurrentProjectItemChangeEvent);

IProjectItem pagx = ItemFactory.Instance.Create("pagx file path") as IProjectItem;
                                ps.Message = "Importing pagx";
                                IEnumerable&amp;lt;IProjectItem&amp;gt; projectItems = await QueuedTask.Run(() =&amp;gt;
                                {
                                    return Project.Current.ImportItem(pagx as IProjectMultiItem, true);
                                }, ps.Progressor);
 ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Unsubscribe(this.ProjectItemChangeSubscription);


  private void CurrentProjectItemChangeEvent(ProjectItemsChangedEventArgs obj)
        {
            if (obj.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add &amp;amp;&amp;amp; obj.ProjectItem.GetType() == typeof(LayoutProjectItem) &amp;amp;&amp;amp; this.getProjectItem)
            {
                this.AddedProjectItem = obj.ProjectItem as LayoutProjectItem;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 05:50:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1025167#M6157</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-02-10T05:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro hangs on layout added by code and when map frame is activated</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1025357#M6161</link>
      <description>&lt;P&gt;Thank you for your suggestion. The problem is, I still have to get the layout from the LayoutProjectItem with GetLayout(); But at least the ImportItem option is faster than to get the item first and then open it. Anyway the layout only hangs when I'm activating the mapframe.&lt;/P&gt;&lt;P&gt;But what I tested now, is to open a layout first with the import layout from the catalog pane and then opening a layout with my code. The interesting thing is, my layout opened by code doesn't hang when I open one with the catalog option first.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 15:02:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-hangs-on-layout-added-by-code-and-when/m-p/1025357#M6161</guid>
      <dc:creator>MyriamFischer</dc:creator>
      <dc:date>2021-02-10T15:02:47Z</dc:date>
    </item>
  </channel>
</rss>

