Select to view content in your preferred language

How to ConvertToGraphics without modifying the layout?

210
1
04-23-2026 07:03 AM
BerendVeldkamp
Frequent Contributor

Page elements such as a scalebar can be converted to a collection of elements (rectangles, texts, ...), using element.ConvertToGraphics(). 

However, this is applied directly to the element on the layout, and after being converted, the scalebar does no longer have a connection to the map.

Is there a way to get the subelements of an element without altering the element itself? Can I for instance clone the element in memory? Or clone the entire layout, and delete the copy afterwards?

0 Kudos
1 Reply
CharlesMacleod
Esri Regular Contributor

Perhaps "Clone"?

 

var lv = LayoutView.Active;
var layout = lv?.Layout;
if (layout == null) return;

QueuedTask.Run(() =>
{
   var sel_elems = lv.GetSelectedElements()
                    .OfType<GraphicElement>()?.ToList() ??
                     new List<GraphicElement>();
   foreach(var elem in sel_elems)
   {
      var ge_clones = elem.Clone("Cloned_").ConvertToGraphics();
      if (ge_clones != null)
      {
         foreach(var ge_clone in ge_clones)
         {
           //TO DO - something with the converted elements
           //...

 

0 Kudos