<?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: Adding Text Graphic via CreateGraphicElements is 30x Slower Than Adding Point/Line/Poly Graphic in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-text-graphic-via-creategraphicelements-is/m-p/1196120#M8492</link>
    <description>&lt;P&gt;Hello, "TheBobScript"&lt;/P&gt;&lt;P&gt;I tried to reproduce your code in 2.9 and 3.0 and was uncesscessful.&amp;nbsp; When I run your code above, everything gets created in less than a second.&amp;nbsp; There was a compile error with your sample above.&amp;nbsp; I made a very slight modification to make it work.&amp;nbsp; I have no idea if that is the difference.&amp;nbsp; If you have different or more complete code, it may be necessary to reproduce the issue.&lt;/P&gt;&lt;P&gt;Here is the code modification I used to replace your lines 30-34 above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; 100; i++)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; MapPoint mapPt = MapPointBuilderEx.CreateMapPoint(i, i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; graphics.Add(new CIMTextGraphic() { Shape = mapPt, Symbol = new CIMSymbolReference() { Symbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 6, "Arial Narrow", "Regular") }, Text = i.ToString() });&lt;/P&gt;&lt;P&gt;&amp;nbsp; names.Add($"Point{i}");&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeff - Layout and arcpy.mp teams&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2022 20:44:26 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2022-07-26T20:44:26Z</dc:date>
    <item>
      <title>Adding Text Graphic via CreateGraphicElements is 30x Slower Than Adding Point/Line/Poly Graphic</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-text-graphic-via-creategraphicelements-is/m-p/1191894#M8404</link>
      <description>&lt;P&gt;I can use CreateGraphicElements to add lines, points and polygons to my layout and performance is great (creating 100 line graphics using CreateGraphicElements takes 0.753 seconds).&lt;/P&gt;&lt;P&gt;Adding 100 text graphics using the same CreateGraphicElements call and structure takes over 25 seconds - performance that is 30x slower than a non-text, geometric graphic (point, line poly).&amp;nbsp; That's something special and not in a good way &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there some secret to adding a CIMTextGraphic to a layout where I could get performance similar to adding a CIMLineGraphic, CIMPointGraphic, etc?&lt;/P&gt;&lt;P&gt;Here's the test code that I have been working with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Layout layout = Project.Current.GetItems&amp;lt;LayoutProjectItem&amp;gt;().FirstOrDefault()?.GetLayout();
GroupElement groupElement1 = LayoutElementFactory.Instance.CreateGroupElement(layout);
CIMElement cimGroupElement = groupElement1.GetDefinition();
cimGroupElement.Name = "Group Element Test - Lines";
groupElement1.SetDefinition(cimGroupElement);

//Creating a GroupElement that only consists of line graphics
var graphics = new List&amp;lt;CIMGraphic&amp;gt;();
var names = new List&amp;lt;string&amp;gt;();
for (int i = 0; i &amp;lt; 100; i++)
{
  List&amp;lt;Coordinate2D&amp;gt; lineCoordinates = new List&amp;lt;Coordinate2D&amp;gt; { new Coordinate2D { X = i, Y = 0 }, new Coordinate2D { X = i, Y = 100 } };
  Polyline polylineTic = PolylineBuilder.CreatePolyline(lineCoordinates);
  CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 1.0, SimpleLineStyle.Solid);
  graphics.Add(new CIMLineGraphic() { Line = polylineTic, Symbol = new CIMSymbolReference() { Symbol = lineSym } });
  names.Add($"Line{i}");
}

//Following line takes 0.75 seconds to execute
LayoutElementFactory.Instance.CreateGraphicElements(groupElement1, graphics.ToArray(), names.ToArray());

//Creating a GroupElement that only consists of text graphics
GroupElement groupElement2 = LayoutElementFactory.Instance.CreateGroupElement(layout);
CIMElement cimGroupElement2 = groupElement2.GetDefinition();
cimGroupElement2.Name = "Group Element Test - Text";
groupElement2.SetDefinition(cimGroupElement2);

graphics = new List&amp;lt;CIMGraphic&amp;gt;();
names = new List&amp;lt;string&amp;gt;();
for (int i = 0; i &amp;lt; 100; i++)
{
  graphics.Add(new CIMTextGraphic() { Shape = new Coordinate2D { X = i, Y = i }, Symbol = new CIMSymbolReference() { Symbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 6, "Arial Narrow", "Regular") }, Text = i.ToString() });
  names.Add($"Point{i}");
}

//Following line takes &amp;gt; 25 seconds to execute;  same usage as above, only difference is the graphics list now contains CIMTextGraphic objects instead of CIMLineGraphic objects
LayoutElementFactory.Instance.CreateGraphicElements(groupElement2, graphics.ToArray(), names.ToArray());&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is &lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/group-performance-issue/m-p/850368" target="_blank" rel="noopener"&gt;another thread&lt;/A&gt; that deals with the degradation of performance when adding elements in multiple nested GroupElements, but in this situation I am using&amp;nbsp;CIMTextGraphic and I am not nesting.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 14:28:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-text-graphic-via-creategraphicelements-is/m-p/1191894#M8404</guid>
      <dc:creator>TheBobScript</dc:creator>
      <dc:date>2022-07-13T14:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Text Graphic via CreateGraphicElements is 30x Slower Than Adding Point/Line/Poly Graphic</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-text-graphic-via-creategraphicelements-is/m-p/1196120#M8492</link>
      <description>&lt;P&gt;Hello, "TheBobScript"&lt;/P&gt;&lt;P&gt;I tried to reproduce your code in 2.9 and 3.0 and was uncesscessful.&amp;nbsp; When I run your code above, everything gets created in less than a second.&amp;nbsp; There was a compile error with your sample above.&amp;nbsp; I made a very slight modification to make it work.&amp;nbsp; I have no idea if that is the difference.&amp;nbsp; If you have different or more complete code, it may be necessary to reproduce the issue.&lt;/P&gt;&lt;P&gt;Here is the code modification I used to replace your lines 30-34 above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; 100; i++)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; MapPoint mapPt = MapPointBuilderEx.CreateMapPoint(i, i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; graphics.Add(new CIMTextGraphic() { Shape = mapPt, Symbol = new CIMSymbolReference() { Symbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 6, "Arial Narrow", "Regular") }, Text = i.ToString() });&lt;/P&gt;&lt;P&gt;&amp;nbsp; names.Add($"Point{i}");&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeff - Layout and arcpy.mp teams&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 20:44:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-text-graphic-via-creategraphicelements-is/m-p/1196120#M8492</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2022-07-26T20:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Text Graphic via CreateGraphicElements is 30x Slower Than Adding Point/Line/Poly Graphic</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-text-graphic-via-creategraphicelements-is/m-p/1196158#M8494</link>
      <description>&lt;P&gt;Hi Jeff.&amp;nbsp; I appreciate the response and correction.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After creating my post, I have had other end users install and use my Add-in in a 2.9.X environment (I have been developing in 2.8.X).&amp;nbsp; They are not reporting the same experience as you are - performance is ideal and there's no perceptible lag.&amp;nbsp; I'm going to assume the world will become a better place for me when I upgrade to 2.9.&lt;/P&gt;&lt;P&gt;Thanks again,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 23:07:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-text-graphic-via-creategraphicelements-is/m-p/1196158#M8494</guid>
      <dc:creator>TheBobScript</dc:creator>
      <dc:date>2022-07-26T23:07:33Z</dc:date>
    </item>
  </channel>
</rss>

