ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMGraticule Class
Members Example Version

CIMGraticule Class
Represents a graticule for a map frame.
Object Model
CIMGraticule ClassCIMGraticule ClassMapPoint ClassCIMGraticule ClassSpatialReference ClassCIMSymbolReference Class
Syntax
Example
Apply a style to Grid and Graticules
//Run within QueuedTask context.
//Get the Style project items in the project
var styleProjectItems = Project.Current?.GetItems<StyleProjectItem>();
//Get the ArcGIS 2D Style Project Item
var styleProjectItem = 
styleProjectItems.OfType<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D");
if (styleProjectItem == null) return;
//Get the grid style item you need
var gridStyleItem = 
styleProjectItem.SearchSymbols(StyleItemType.Grid, "Blue Vertical Label Graticule").FirstOrDefault();
if (gridStyleItem == null) return;
var symbolItemName = gridStyleItem.Name;
var girdGraticuleObject = gridStyleItem.GetObject() as CIMMapGrid;

var mapFrame = layout.GetElements().OfType<MapFrame>().FirstOrDefault();
var cmf = mapFrame.GetDefinition() as CIMMapFrame;
//note, if page units are _not_ inches then grid's gridline
//lengths and offsets would need to be converted to the page units
var mapGrids = new List<CIMMapGrid>();
if (cmf.Grids != null)
  mapGrids.AddRange(cmf.Grids);

//var cimMapGrid = SymbolStyleItem.GetObject() as CIMMapGrid;

switch (girdGraticuleObject)
{
  case CIMGraticule:
    var gridGraticule = girdGraticuleObject as CIMGraticule;
    gridGraticule.Name = symbolItemName;
    gridGraticule.SetGeographicCoordinateSystem(mapFrame.Map.SpatialReference);
    //assign grid to the frame             
    mapGrids.Add(gridGraticule);

    break;
  case CIMMeasuredGrid:
    var gridMeasure = girdGraticuleObject as CIMMeasuredGrid;
    gridMeasure.Name = symbolItemName;
    gridMeasure.SetProjectedCoordinateSystem(mapFrame.Map.SpatialReference);
    //assign grid to the frame
    mapGrids.Add(gridMeasure);

    break;
  case CIMReferenceGrid:
    var gridReference = girdGraticuleObject as CIMReferenceGrid;
    gridReference.Name = symbolItemName;
    //assign grid to the frame
    mapGrids.Add(gridReference);
    break;
}

cmf.Grids = mapGrids.ToArray();
mapFrame.SetDefinition(cmf);
Inheritance Hierarchy

System.Object
   ArcGIS.Core.CIM.CIMObject
      ArcGIS.Core.CIM.CIMMapGrid
         ArcGIS.Core.CIM.CIMGraticule

Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also