<?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 ArcGIS Pro 3.1 Layout GroupElements are broken in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-3-1-layout-groupelements-are-broken/m-p/1302033#M9962</link>
    <description>&lt;P&gt;In 2.9/net48 we have some code were we create a GroupElement first and then create some further elements afterwards which have the GroupElement as their container. All this child elements got this GroupElement as their parent. In 3.1 SDK this behaviour seems to be broken or atleast it has changed.&lt;/P&gt;&lt;P&gt;In 3.1 SDK it seems that all ParentElements get nulled if another element is created within that group. That probably leads to many NullPointerExceptions which we got now after upgrading to 3.1. This behaviour is event watchable when assigning the child elements straight up when calling the CreateGroupElement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var group1 = ElementFactory.Instance.CreateGroupElement(layout, new List&amp;lt;Element&amp;gt; (), "group1");

var test1 = ElementFactory.Instance.CreateMapFrameElement(group1, frameBounds, templateMap);
// test1.GetParent() &amp;gt; group1 
test1.SetHeight(100.0); // &amp;gt; works
var test2 = ElementFactory.Instance.CreateMapFrameElement(group1, frameBounds, templateMap);
// test1.GetParent() &amp;gt; null
// test2.GetParent() &amp;gt; group1
test1.SetHeight(100.0); // &amp;gt; NullPointerException
test2.SetHeight(100.0); // &amp;gt; works

var test3 = ElementFactory.Instance.CreateMapFrameElement(layout, frameBounds, templateMap);
var test4 = ElementFactory.Instance.CreateMapFrameElement(layout, frameBounds, templateMap);
var group2 = ElementFactory.Instance.CreateGroupElement(layout, new List&amp;lt;Element&amp;gt; { test3, test4 }, "group2");
// test3.GetParent() &amp;gt; null
// test4.GetParent() &amp;gt; null
test3.SetHeight(100.0); // &amp;gt; NullPointerException
test4.SetHeight(100.0); // &amp;gt; NullPointerException&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There were alot of changes to the Element-/Layout factories. Many code snippets just went broke as soon as we updated to 3.1 and ran totally fine pre 3.x.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2023 15:10:11 GMT</pubDate>
    <dc:creator>marco_vertigis</dc:creator>
    <dc:date>2023-06-22T15:10:11Z</dc:date>
    <item>
      <title>ArcGIS Pro 3.1 Layout GroupElements are broken</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-3-1-layout-groupelements-are-broken/m-p/1302033#M9962</link>
      <description>&lt;P&gt;In 2.9/net48 we have some code were we create a GroupElement first and then create some further elements afterwards which have the GroupElement as their container. All this child elements got this GroupElement as their parent. In 3.1 SDK this behaviour seems to be broken or atleast it has changed.&lt;/P&gt;&lt;P&gt;In 3.1 SDK it seems that all ParentElements get nulled if another element is created within that group. That probably leads to many NullPointerExceptions which we got now after upgrading to 3.1. This behaviour is event watchable when assigning the child elements straight up when calling the CreateGroupElement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var group1 = ElementFactory.Instance.CreateGroupElement(layout, new List&amp;lt;Element&amp;gt; (), "group1");

var test1 = ElementFactory.Instance.CreateMapFrameElement(group1, frameBounds, templateMap);
// test1.GetParent() &amp;gt; group1 
test1.SetHeight(100.0); // &amp;gt; works
var test2 = ElementFactory.Instance.CreateMapFrameElement(group1, frameBounds, templateMap);
// test1.GetParent() &amp;gt; null
// test2.GetParent() &amp;gt; group1
test1.SetHeight(100.0); // &amp;gt; NullPointerException
test2.SetHeight(100.0); // &amp;gt; works

var test3 = ElementFactory.Instance.CreateMapFrameElement(layout, frameBounds, templateMap);
var test4 = ElementFactory.Instance.CreateMapFrameElement(layout, frameBounds, templateMap);
var group2 = ElementFactory.Instance.CreateGroupElement(layout, new List&amp;lt;Element&amp;gt; { test3, test4 }, "group2");
// test3.GetParent() &amp;gt; null
// test4.GetParent() &amp;gt; null
test3.SetHeight(100.0); // &amp;gt; NullPointerException
test4.SetHeight(100.0); // &amp;gt; NullPointerException&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There were alot of changes to the Element-/Layout factories. Many code snippets just went broke as soon as we updated to 3.1 and ran totally fine pre 3.x.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 15:10:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-3-1-layout-groupelements-are-broken/m-p/1302033#M9962</guid>
      <dc:creator>marco_vertigis</dc:creator>
      <dc:date>2023-06-22T15:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1 Layout GroupElements are broken</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-3-1-layout-groupelements-are-broken/m-p/1302335#M9971</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your post.&amp;nbsp; I am able to duplicate your issues at 3.1.&amp;nbsp;I have logged an issue with the Layout team for this bug to be fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a work around for this bug.&amp;nbsp; If you are able to&amp;nbsp; name your elements when creating them, you can call Layout.FindElement&amp;nbsp; &amp;nbsp;(&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic29299.html" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic29299.html&lt;/A&gt;)&amp;nbsp; using that name before you need to reference the element.&amp;nbsp; Doing this, you will find that the object is populated correctly and no null reference exceptions should be thrown.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, here is your code with the first mapFrame element correctly showing the parent after the second map frame has been created.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var group1 = ElementFactory.Instance.CreateGroupElement(layout, new List&amp;lt;Element&amp;gt;(), "group1");

var test1 = ElementFactory.Instance.CreateMapFrameElement(group1, frameBounds, templateMap, "MF1");
var parent = test1.GetParent(); //  &amp;gt; group1 
test1.SetHeight(100.0); // &amp;gt; works

var test2 = ElementFactory.Instance.CreateMapFrameElement(group1, frameBounds, templateMap, "MF2");
parent = test1.GetParent(); //  &amp;gt; null 
parent = test2.GetParent(); //  &amp;gt; group1

// re-get the element
test1 = layout.FindElement("MF1") as MapFrame;
parent = test1.GetParent();   // group1
test1.SetHeight(100.0); // &amp;gt; works&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 03:28:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-pro-3-1-layout-groupelements-are-broken/m-p/1302335#M9971</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2023-06-23T03:28:10Z</dc:date>
    </item>
  </channel>
</rss>

