<?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 Determining an Element's Envelope Without Adding to GroupElement/Layout in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/determining-an-element-s-envelope-without-adding/m-p/1131440#M7572</link>
    <description>&lt;P&gt;I need to determine the width of a graphic (typically CIMTextGraphic) so that I can place subsequent graphics as they relate to the location of the preceding graphic.&lt;/P&gt;&lt;P&gt;I can do this by creating a (throw-away/temporary) GroupElement and then retrieving the envelope like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Coordinate2D pnt = new Coordinate2D(xCanvas, yCanvas);
GroupElement dummyGE;
GroupElement groupElement;
List&amp;lt;CIMGraphic&amp;gt; newElements = new List&amp;lt;CIMGraphic&amp;gt;();

await QueuedTask.Run(() =&amp;gt; {
	dummyGE = LayoutElementFactory.Instance.CreateGroupElement(myLayout));
	
	//create foreign text
	CIMTextGraphic tg = new CIMTextGraphic { Symbol = myTextSymbol.MakeSymbolReference(), Text = "Hallo Venn!", Shape = pnt.ToMapPoint() };
	CIMGraphicElement graphic = new CIMGraphicElement() { Graphic = tg };
	LayoutElementFactory.Instance.CreateElement(dummyGE, graphic);
	Element tmpElem = dummyGE.Elements[dummyGE.Elements.Count - 1];
	Envelope tmpEnv = tmpElem.GetBounds();
	pnt = new Coordinate2D(xCanvas + (tmpEnv.Width + 1), yCanvas);
	tg.Shape = pnt.ToMapPoint();
	newElements.Add(tg);
	
	//create english text
	tg = new CIMTextGraphic { Symbol = myTextSymbol.MakeSymbolReference(), Text = "Hello Friend!", Shape = pnt.ToMapPoint() };
	graphic = new CIMGraphicElement() { Graphic = tg };
	LayoutElementFactory.Instance.CreateElement(dummyGE, graphic);
	tmpElem = dummyGE.Elements[dummyGE.Elements.Count - 1];
	tmpEnv = tmpElem.GetBounds();
	pnt = new Coordinate2D(xCanvas + (tmpEnv.Width + 1), yCanvas);
	tg.Shape = pnt.ToMapPoint();
	newElements.Add(tg);
	
	myLayout.DeleteElement(dummyGE);
	
	groupElement = LayoutElementFactory.Instance.CreateGroupElement(myLayout);
	LayoutElementFactory.Instance.CreateGraphicElements(groupElement, newElements, null);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using this method is detrimental to performance.&amp;nbsp; If I am iteratively using the above code it can take nearly a minute to add ~100 elements.&lt;/P&gt;&lt;P&gt;If I don't need to determine the location based on preceding elements I can avoid the creation of the 'dummy' element;&amp;nbsp; I just add the new element to the CIMGraphic list and once I have all elements added, use a single call (LayoutElementFactory.Instance.CreateGraphicElements) to add to a GroupElement/Layout.&amp;nbsp; That works great, but it doesn't help me when trying to create elements as the relate to other new elements.&lt;/P&gt;&lt;P&gt;Anyone out there have a method to determine the extent of an element without adding it the layout?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jan 2022 23:23:09 GMT</pubDate>
    <dc:creator>TheBobScript</dc:creator>
    <dc:date>2022-01-06T23:23:09Z</dc:date>
    <item>
      <title>Determining an Element's Envelope Without Adding to GroupElement/Layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/determining-an-element-s-envelope-without-adding/m-p/1131440#M7572</link>
      <description>&lt;P&gt;I need to determine the width of a graphic (typically CIMTextGraphic) so that I can place subsequent graphics as they relate to the location of the preceding graphic.&lt;/P&gt;&lt;P&gt;I can do this by creating a (throw-away/temporary) GroupElement and then retrieving the envelope like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Coordinate2D pnt = new Coordinate2D(xCanvas, yCanvas);
GroupElement dummyGE;
GroupElement groupElement;
List&amp;lt;CIMGraphic&amp;gt; newElements = new List&amp;lt;CIMGraphic&amp;gt;();

await QueuedTask.Run(() =&amp;gt; {
	dummyGE = LayoutElementFactory.Instance.CreateGroupElement(myLayout));
	
	//create foreign text
	CIMTextGraphic tg = new CIMTextGraphic { Symbol = myTextSymbol.MakeSymbolReference(), Text = "Hallo Venn!", Shape = pnt.ToMapPoint() };
	CIMGraphicElement graphic = new CIMGraphicElement() { Graphic = tg };
	LayoutElementFactory.Instance.CreateElement(dummyGE, graphic);
	Element tmpElem = dummyGE.Elements[dummyGE.Elements.Count - 1];
	Envelope tmpEnv = tmpElem.GetBounds();
	pnt = new Coordinate2D(xCanvas + (tmpEnv.Width + 1), yCanvas);
	tg.Shape = pnt.ToMapPoint();
	newElements.Add(tg);
	
	//create english text
	tg = new CIMTextGraphic { Symbol = myTextSymbol.MakeSymbolReference(), Text = "Hello Friend!", Shape = pnt.ToMapPoint() };
	graphic = new CIMGraphicElement() { Graphic = tg };
	LayoutElementFactory.Instance.CreateElement(dummyGE, graphic);
	tmpElem = dummyGE.Elements[dummyGE.Elements.Count - 1];
	tmpEnv = tmpElem.GetBounds();
	pnt = new Coordinate2D(xCanvas + (tmpEnv.Width + 1), yCanvas);
	tg.Shape = pnt.ToMapPoint();
	newElements.Add(tg);
	
	myLayout.DeleteElement(dummyGE);
	
	groupElement = LayoutElementFactory.Instance.CreateGroupElement(myLayout);
	LayoutElementFactory.Instance.CreateGraphicElements(groupElement, newElements, null);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using this method is detrimental to performance.&amp;nbsp; If I am iteratively using the above code it can take nearly a minute to add ~100 elements.&lt;/P&gt;&lt;P&gt;If I don't need to determine the location based on preceding elements I can avoid the creation of the 'dummy' element;&amp;nbsp; I just add the new element to the CIMGraphic list and once I have all elements added, use a single call (LayoutElementFactory.Instance.CreateGraphicElements) to add to a GroupElement/Layout.&amp;nbsp; That works great, but it doesn't help me when trying to create elements as the relate to other new elements.&lt;/P&gt;&lt;P&gt;Anyone out there have a method to determine the extent of an element without adding it the layout?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 23:23:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/determining-an-element-s-envelope-without-adding/m-p/1131440#M7572</guid>
      <dc:creator>TheBobScript</dc:creator>
      <dc:date>2022-01-06T23:23:09Z</dc:date>
    </item>
  </channel>
</rss>

