How to set Halo property of North Arrow (Pro SDK)

277
3
Jump to solution
06-14-2018 12:19 PM
Highlighted
New Contributor II

If you select a north arrow in a layout in ArcGIS Pro and go to Symbol>Properties>Halo, you can set the halo property of a north arrow.

Does anyone know how to access this property programmatically in the ArcGIS Pro SDK?

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Contributor
//I am assuming the selected item is a north arrow
      var northArrow =  LayoutView.Active.GetSelectedElements().First();
      QueuedTask.Run(() =>
      {
        //CIMTopoNorthArrow is a different beast entirely...
        var cim = northArrow.GetDefinition() as CIMMarkerNorthArrow;
        //this halo symbol is 50% transparent, no outline (i.e. 0 width)
        ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(
          SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.CreateRGBColor(0,0,0,50)),
          SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB,0));
        ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSize = 3;//size of the halo
        //set it back
        northArrow.SetDefinition(cim);
      });

View solution in original post

Reply
0 Kudos
3 Replies
Highlighted
Esri Contributor
//I am assuming the selected item is a north arrow
      var northArrow =  LayoutView.Active.GetSelectedElements().First();
      QueuedTask.Run(() =>
      {
        //CIMTopoNorthArrow is a different beast entirely...
        var cim = northArrow.GetDefinition() as CIMMarkerNorthArrow;
        //this halo symbol is 50% transparent, no outline (i.e. 0 width)
        ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(
          SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.CreateRGBColor(0,0,0,50)),
          SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB,0));
        ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSize = 3;//size of the halo
        //set it back
        northArrow.SetDefinition(cim);
      });

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor II

Works great, thank you! I was casting northArrow.GetDefinition() as CIMNorthArrow which was just the same as accessing the NorthArrow property of NorthArrowStyleItem.

Reply
0 Kudos
Highlighted
Esri Contributor

Two things that may help:

1. When working with the CIM, I often set a line like this in my code: var str = cim.ToXML(); 

Then, in the debugger, I set a breakpoint on that line and now I can hover over "str" and use the text or xml viewer built in to visual studio to examine "str". [I am not sure if you realize but the CIM definition is serializable to XML]. Note that the "type" of each element is shown in the XML as well as the structure.

2. Use the CIM Viewer. It is a utility we (Pro SDK team) wrote for examining the CIM. You can find it here: arcgis-pro-sdk-cim-viewer

It allows you to see the CIM definition of maps, layers, layouts, and layout elements as well as edit their xml.